Bit Manipulation Based

Asked atExpediaHHashedIn
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
  1. 01Confirm value range, signedness, and frequency guarantees.
  2. 02Map each requirement to a bitwise property.
  3. 03Choose masks, XOR, shifts, or per-bit counts.
  4. 04State the bit invariant.
  5. 05Verify high-bit and zero cases.

Reference answer

Then expect these follow-ups

  • How do per-bit counts solve the thrice-except-once variant?

    Tests: constraint adaptation

  • When should you use a BitSet instead of an integer mask?

    Tests: follow-up reasoning

Free to read · better with Enzo

Practice this out loud with Enzo

Enzo runs it as a mock interview, pushes back with follow-ups, and grades you on the rubric.

Next question