We use analytics and advertising cookies to understand how the site is used and whether our ads on Facebook and Instagram work. They are set only if you accept. See our Privacy Policy for details.
Matrix problems test index discipline more than algorithmic insight: rotating in place, walking a spiral, or using the first row and column as marker storage to hit O(1) space. Many grid problems are really graph problems - islands and flood-fill belong to BFS and DFS - so check which question is actually being asked. Write the index arithmetic out on paper first; it is where the bugs live.
A grid input, spiral or diagonal traversal, or an in-place transformation constraint.
22 problems. Each one runs in an in-browser editor against real test cases, with hints and a worked solution.
The patterns cheat sheet covers all of these in one page - what each one looks like in a problem statement, and the template that follows.