Given two integers $$$A$$$ and $$$B$$$, find $$$A$$$ $$$\oplus$$$ $$$($$$ $$$A$$$ $$$+$$$ $$$1$$$ $$$)$$$ $$$\oplus$$$ $$$($$$ $$$A$$$ $$$+$$$ $$$2$$$ $$$)$$$ $$$\oplus$$$ $$$\dots$$$ $$$\oplus$$$ $$$B$$$ where $$$A$$$ $$$<=$$$ $$$B$$$
No, not in linear time
You can use a trick, that 1 xor 2 xor .. xor (4 * x — 1) = 0.
And A xor A + 1 xor .. xor B = (1 xor 2 xor .. xor (A — 1)) xor (1 xor 2 .. xor B)
https://mirror.codeforces.com/blog/entry/2154
The XOR sum of numbers from 1 to m equals: