K
kavyasub5
11 Sep 2026, 18:36
Finally got AC after 3 WAs. Sharing what I missed.
XOR cancels equal numbers, and x & (x - 1) clears the lowest set bit. Both give O(1) space solutions here.
Finally got AC after 3 WAs. Sharing what I missed.
XOR cancels equal numbers, and x & (x - 1) clears the lowest set bit. Both give O(1) space solutions here.
Watch out for integer overflow in Java on the large test.
You can avoid the extra array and do it in O(1) space.
Nice. Got asked a variant of this in an interview.
Sign in to reply.