Problem · Array
Dominating XOR Pairs
Learn this problemProblem statement
Given an array arr of positive integers, count the unordered index pairs (i, j) such that:
0 ≤ i < j < arr.length(arr[i] XOR arr[j]) > (arr[i] AND arr[j])
Return the number of qualifying pairs as a long.
Function
dominatingXorPairs(arr: int[]) → longExamples
Example 1
arr = [4, 3, 5, 2]return = 4The qualifying value pairs are (4, 3), (4, 2), (3, 5), and (5, 2). For each pair, the XOR value is greater than the AND value, so the result is 4.
Constraints
1 ≤ arr.length ≤ 2 × 10^51 ≤ arr[i] ≤ 10^9
More IBM problems
- Parent Process NumberOA · Seen Jul 2026
- Request Retry CountOA · Seen Jul 2026
- Count Strictly Increasing Subsequences of Length 3OA · Seen Jul 2026
- Maximum Requests in a Time WindowOA · Seen Jul 2026
- Query Type Frequency WindowOA · Seen Jul 2026
- Minimum Number of Non-Empty Disjoint SegmentsOA · Seen Jul 2026
- Spam Text ClassificationOA · Seen Jul 2026
- Count Ideal NumbersOA · Seen Jun 2026