You are given an array \(A\) of length \(N\). Find the number of subarrays of length greater than one whose Bitwise AND and Bitwise OR are the same.
Input Format:
- The first line contains an integer \(T\), denoting the number of test cases.
- The first line of each test case contains an integer \(N\), denoting the length of the array \(A\).
- The second line of each test case contains \(N\) space-separated integers, denoting the elements of array \(A\).
Output Format:
For each test case, print the number of subarrays of length greater than one whose Bitwise AND and Bitwise OR are the same.
Constraints:
\(1 <= T <= 10\)
\(1 <= N <= 10^5\)
\(1 <= A[i] <= 10^5\)
First test case:-
Subarray [2, 2], [1, 1] has Bitwise AND and Bitwise OR the same. Hence, our answer is 2.
Second test case:-
Subarray [3, 3], [3, 3], [3, 3, 3] has Bitwise AND and Bitwise OR the same. Hence, our answer is 3.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor