Special Subarray
Practice
4.4 (16 votes)
Binary search
Algorithms
Problem
46% Success 2320 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
You are given an array \(A\) of length \(N\). A subarray is called special if the XOR and Sum of the subarray are the same. Find the number of special subarrays of \(A\).
Input Format
- The first line contains an integer \(T\), which denotes the number of test cases.
- The first line of each test case contains an integer \(N\), which denotes the length of array \(A\).
- The second line of each test case contains \(N\) space-separated integers, denoting elements of array \(A\).
Output Format
For each test case, print the number of special subarrays of \(A\).
Constraints
\(1 \leq T \leq 10 \\ 1 \leq N \leq 10^5 \\ 1 \leq A_i \leq 10^9\)
Submissions
Please login to view your submissions
Similar Problems
Points:30
8 votes
Tags:
AlgorithmsBinary Search
Points:30
3 votes
Tags:
AlgorithmsBinary SearchImplementationMediumSearching
Points:30
17 votes
Tags:
Binary SearchEasySorting
Editorial