Data Structures & AlgorithmsModerate
How many contiguous subarrays of length exactly 3 in 1 2 3 4 4 1 5 7 have bitwise XOR equal to 0?
- A. 4
- B. 2
- C. 0
- D. 1
Correct answer: B. 2
XOR of three values is zero exactly when the third equals the XOR of the first two, which is a direct test per window. Counting the complement, testing the sum, or checking pairs answers different questions.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- How many contiguous subarrays of 3 1 4 1 5 9 2 have (sum − length) divisible by 4?
- How many contiguous subarrays of 1 2 3 4 5 6 have a sum of SQUARES divisible by 5?
- For each contiguous subarray of 4 2 7 1 5 3 6 2, locate the FIRST position (in the original array) where its minimum value occurs. How…
- How many contiguous subarrays of 2 7 1 8 2 8 of length at least 2 have a sum that leaves remainder 1 when divided by 4?
- How many contiguous subarrays of 5 1 6 2 7 3 8 contain EXACTLY two values that are at least 5?
- What is the length of the longest contiguous subarray of 1 6 2 7 3 5 4 8 1 9 that contains equally many values ≥ 5 and values < 5?