题目描述
Given an array arr[] of N integers, the task is to find the number of pairs in the array whose XOR is odd.
Example 1:
Input: N = 3, arr[] = {1, 2, 3}
Output: 2
Explanation: All pairs of array
1 ^ 2 = 3
1 ^ 3 = 2
2 ^ 3 = 1
Example 2:
Input: N = 2, arr[] = {1, 2}
Output: 1
Explanation: 1^2 =3 which is odd.
Your Task:
This is a function problem. You don't need to take any input, as it is already accomplished by the driver code. You just need to complete the function countXorPair() that takes array arr and integer N as parameters and returns the desired output.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(1).
Constraints:
1 ≤ N ≤ 10^{6}
输入格式
见题面
输出格式
见题面