Description
Solutions
Submission
Dominating X Or Pairs
🔥 FULLTIME

For an array arr of n positive integers, count the unordered pairs (i, j) (0 <= i < j < n) where arr[i] XOR arr[j] > arr[i] AND arr[j]. XOR denotes the bitwise XOR operation and AND denotes the bitwise AND operation.

Function Description

Complete the function dominatingXorPairs in the editor below.

dominatingXorPairs has the following parameter:

  • int arr[n]: an array of integers
  • Returns

  • long int: the number of good pairs
  • Example 1:

    Input:  n = 4, arr = [4, 3, 5, 2]
    Output: 4
    Explanation:
    For the first line: a. arr[0] = 4, arr[1] = 3 b. 4 XOR 3 = 7 c. 4 AND 3 = 0 d. 7 > 3 There are 4 good pairs where XOR > AND shows true. Return 4.
    Constraints:
      N/A (if you happen to know about it, feel free to contact us. TY!
    Testcase

    Result
    Case 1

    input:

    output: