Topic 20 of 20
Matrix manipulation, number tricks and coordinate geometry that show up in interviews.
This final topic collects the maths-flavoured questions interviewers still like to ask. Many are really about matrices: rotating an image in place (transpose then reverse each row), walking a matrix in spiral order with shrinking boundaries, or reusing the first row and column as marker storage to zero a matrix in O(1) extra space.
Others are about numbers: multiplying big numbers stored as strings digit by digit, converting between bases (such as spreadsheet column titles), and spotting that repeatedly applying a function must eventually cycle, which lets you reuse fast & slow pointers from the Linked List topic. Geometry questions usually reduce to hashing: represent a slope as a reduced fraction (divide both parts by their gcd) or store points in a map, then count.
None of these need advanced mathematics. What they test is careful implementation (off-by-one boundaries, overflow, precision), so write clean helper functions and test small cases by hand.
A digit function that must cycle; fast & slow pointers on numbers.
Bijective base-26: the off-by-one that trips everyone.
Transpose and reverse, in place; asked very often.
Boundary-shrinking traversal.
Use the first row and column as markers for O(1) space.
Encode old and new state in the same cell.
Grade-school multiplication with index arithmetic.
Slope hashing with gcd-reduced fractions.