← Discussions on Number of 1 Bits
S sairao5
15 Oct 2026, 11:37

Asked in my NVIDIA OA last week.

XOR cancels equal numbers, and x & (x - 1) clears the lowest set bit. Both give O(1) space solutions here.

1 reply

teja.s 1 hour, 10 minutes ago

Same idea, but I used a deque. Works fine.

Sign in to reply.