Ten problems that drill the math & geometry pattern from Lesson 26 — the in-place grid manipulations and digit-level number tricks that round out the NeetCode 150. Open a problem, try it yourself first, then read how to reach the solution. Each solution here was actually run and tested.
How to practise. For the grid problems, draw the 3×3 example and write the exact index mapping before you code — most bugs are a swapped
i/jor the wrong mutation order. For the number problems, say out loud where overflow would bite in a 32-bit language even though Python is immune. Stuck for ~20 minutes? Read the approach, close the page, and re-solve from memory the next day.
The 10 problems
- 1Plus One (LeetCode 66)EasyAdd one to a number stored as a digit array: walk from the right, carry through the 9s, prepend 1 if needed.arrow_forward
- 2Happy Number (LeetCode 202)EasyDecide if repeatedly summing squared digits reaches 1: treat the numbers as a list and detect a cycle.arrow_forward
- 3Roman to Integer (LeetCode 13)EasyConvert a Roman numeral to an integer: subtract a symbol when a bigger one follows it, otherwise add it.arrow_forward
- 4Rotate Image (LeetCode 48)MediumRotate an n×n matrix 90° clockwise in place: transpose across the diagonal, then reverse each row.arrow_forward
- 5Spiral Matrix (LeetCode 54)MediumRead a matrix in clockwise spiral order: take the top row, rotate what is left counter-clockwise, repeat.arrow_forward
- 6Set Matrix Zeroes (LeetCode 73)MediumZero every row and column that holds a 0, in place, by storing the markers in the first row and column.arrow_forward
- 7Pow(x, n) (LeetCode 50)MediumCompute x to the power n in O(log n) by squaring x and multiplying it in for each set bit of n.arrow_forward
- 8Multiply Strings (LeetCode 43)MediumMultiply two numeric strings without converting: digit i × digit j lands at positions i+j and i+j+1.arrow_forward
- 9Game of Life (LeetCode 289)MediumAdvance Conway's Game of Life one step in place by encoding old and new state in each cell, then taking mod 2.arrow_forward
- 10Reverse Integer (LeetCode 7)MediumReverse the digits of a 32-bit integer by popping digits with % 10, and return 0 if the result overflows.arrow_forward