← Whiteboard questions

Pattern

Bit Manipulation

Use bits when values act as small flags, or when and, or, xor and shifts replace loops. Xor cancels equal values, and a shift halves or doubles a number. These solutions usually take O(n) or O(bits) time with O(1) memory.

Bit Manipulation interview questions and solutions