Skip to main content
00001011
easyBlind 75

Number of 1 Bits

Number of 1 Bits tests whether you're comfortable manipulating bits directly. The clean trick is `n &= n - 1`, which clears the lowest set bit each iteration, so you loop exactly once per one-bit. Interviewers watch whether you reach for bitwise reasoning instead of converting to a string and counting characters.

Binary SearchBit Manipulation

Learn this pattern

Bit Manipulation

Bit manipulation uses XOR, shifts, and masks to solve problems in O(1) space that would otherwise need hash maps. About 5 core tricks -- XOR for uniqueness, bit checks, Brian Kernighan's count -- cover 90% of interview bit problems.

Coco
Fin

Meet your coaches

Talk through the problem while you code. Signed-in reps become prep memory for the next session.

Chat with Fin or Coco right now on mobile.

Start talking through the problem here. Switch to desktop when you're ready to code and run tests.

Start coaching session
1Number of 1 Bitseasy
Based onLeetCode

Desktop required

Sorry - mobile cannot run the editor and tests yet. Use the next step below or email yourself a link to continue on desktop.

Read the pattern guide

Bit Manipulation gives you a useful next rep while you are still on your phone.