~/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.

Math & matrices

Math and matrices

Digit-by-digit arithmetic, matrix rotation and in-place tricks.

Notes

Recognise it when: the input is a grid to transform in place, or numbers too big (or too awkward) to handle directly.

  • Rotate a square matrix 90° clockwise: transpose, then reverse each row. Layers work too.
  • In-place markers: reuse the first row and column (or a sign bit) to remember what to change, so no extra matrix is needed.
  • Digit arithmetic: walk from the least significant digit, carry to the next; a result of length len(a) + len(b) is enough for a product.
  • Cycles in a sequence of numbers (e.g. repeatedly transforming a value): detect them with a set or with fast/slow pointers.

Common mistakes: changing cells you still need to read; forgetting the final carry; off-by-one on layer boundaries.

9 problems

Interview roadmap

Math & matrices Digit arithmetic, rotating and marking grids in place.

esc