776. Subarrays With XOR Atleast K
Given an array of positive integers nums of length n and a non‑negative integer k.
Return the number of contiguous subarrays whose bitwise XOR of all elements is greater than or equal to k.
Example 1:
Input:Â nums = [3,1,2,3], k = 2
Output:Â 6
Explanation:
The valid subarrays with XOR >= 2 are [3] at index 0, [3, 1] at indices 0 - 1, [3, 1, 2, 3] at indices 0 - 3, [1, 2] at indices 1 - 2, [2] at index 2, and [3] at index 3; there are 6 in total.
Example 2:
Input:Â nums = [0,0,0], k = 0
Output:Â 6
Explanation:
Every contiguous subarray yields XOR = 0, which meets k = 0. There are 6 such subarrays in total.
Now Your Turn!
Pick the correct output for the given inputInput: nums = [609004943, 940992571, 770854579], k= 703771909
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 1 <= nums.length <= 105
- 0 <= nums[i] <= 109
- 0 <= k <= 109