Triples with Bitwise AND Equal To Zero
Given an integer array nums, return the number of AND triples.
An AND triple is a triple of indices (i, j, k) such that:
0 <= i < nums.length0 <= j < nums.length0 <= k < nums.lengthnums[i] & nums[j] & nums[k] == 0, where&represents the bitwise-AND operator.
Example 1
Input
nums = [2,1,3]Output
12There are 12 index triples
(i, j, k) whose bitwise AND value is 0.Example 2
Input
nums = [0,0,0]Output
27All 27 possible triples have bitwise AND equal to
0 because every value is 0.Constraints
- 1 <= nums.length <= 1000
- 0 <= nums[i] < 2^16