710. XOR of numbers in a given range
Given two integers L and R. Find the XOR of the elements in the range [L , R].
Example 1:
Input : L = 3 , R = 5
Output : 2
Explanation : answer = (3 ^ 4 ^ 5) = 2.
Example 2:
Input : L = 1, R = 3
Output : 0
Explanation : answer = (1 ^ 2 ^ 3) = 0.
Now Your Turn!
Pick the correct output for the given inputInput : L = 4, R = 10
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 1 <= L <= R <= 109