← practice

Bit Manipulation

XOR tricks · Kernighan · masks
Bit problems reward knowing a handful of core tricks: XOR cancels duplicates (a^a=0), n & (n-1) clears the lowest set bit, n & (-n) isolates it. Recognize these and most bit problems collapse to a one-liner. Reviewers love the elegant O(1)-space solutions these enable.

6 problems