DDSA Solutions

Bit Manipulation

54 problems · 36 with full explanations

16 Easy20 Medium1 Hard
Bit manipulation uses bitwise operators (&, |, ^, ~, <<, >>) for compact and fast solutions. Key tricks: x & (x-1) clears lowest set bit, x ^ x = 0 (XOR cancellation), and bitmask DP represents subsets as integers. In C#, use int (32-bit) or long (64-bit) for bitmasking.

How to practice

To practice Bit Manipulation problems effectively, start with the Easy problems listed below, trace through each solution on paper, then re-implement without looking. When you can recognise the bit manipulation pattern within 30 seconds of reading a new problem, move on to Medium difficulty. Use the related topic pages and our study guide for a structured progression.

Open the full study guide →

Start here (Easy + explained)

All Bit Manipulation problems