~/problems
Problems
Basics first, then the classics, then company-style assessments. Every problem has tests you run right here; multi-level ones unlock as you go. See the roadmap.
Bit manipulation (IP / CIDR)
IPv4 as a 32-bit int; lowest set bit for block sizes.
Main path: 8 problems, about 3 hours.
Notes
Recognise it when: IP addresses and CIDR, flags, powers of two, subsets.
- IPv4 as an int:
n = (n << 8) | int(octet); back again:(n >> shift) & 0xFF. - Lowest set bit:
x & -x, which is also the largest aligned block starting at x. - A
/lenblock has size1 << (32 - len), and its start must be a multiple of that size. - Is a power of two:
x and not (x & (x - 1)). Set-bit count:x.bit_count().
Gotchas: at x == 0 everything is aligned, so cap the block at the whole space.
15 problems
Interview roadmap
Bit manipulation Masks, shifts and IP-address arithmetic.
- Play first: The Bit Check 1-minute game Bit trick: n & (n − 1)
- IPv4 addresses as 32-bit integers basics py · c++ · java easy
- Watering rota as weekday bitmasks py · c++ · java easy
- Power of Two code the boss 2 levels py · c++ · java easy
- Single Number ▶ boss game py · c++ · java easy
- Missing Number ▶ boss game py · c++ · java easy
- Sum of Two Integers py · c++ · java medium
- Palindromic paths toward the root Uber py · c++ · java hard
- Ordered CIDR firewall assessment 2 levels Databricks py · c++ · java medium
More practice: 7 problems
- Number of 1 Bits py · c++ · java easy
- Counting Bits py · c++ · java easy
- Reverse Bits py · c++ · java easy
- Add Binary py · c++ · java easy
- Cover an IP range with CIDR blocks py · c++ · java medium
- Distinct goodness values CitadelScale AI py · c++ · java medium
- IPv4 / CIDR iterator assessment 5 levels OpenAI py · c++ · java medium