The XOR of a run is all its values combined with the ^ operator. Return how many contiguous runs of nums have an XOR equal to k.
The starter code tries every start and end. It is correct but too slow. Make it fast.
Example 1
Input:
count_subarrays_xor_k([4, 2, 2, 6, 4], 6)
Output:
4
The runs are [4, 2], [4, 2, 2, 6], [2, 2, 6] and [6].
Example 2
Input:
count_subarrays_xor_k([5, 6, 7, 8, 9], 5)
Output:
2
The runs are [5] and [5, 6, 7, 8, 9].
0 <= len(nums) <= 2 * 10**50 <= nums[i] <= 10**90 <= k <= 2**30No results yet
Run your code to check it against the examples, or submit to run every test.