Advanced Matrix Problems for Coding Interviews
51 advanced Matrix problems from real coding interviews, each with test cases you can run online. By difficulty they split into 0 basic, 0 intermediate and 51 advanced. The companies that ask them most often are Google, Amazon, Microsoft, Meta.
Solve a few problems of each level, name the pattern after each one and revisit the ones that needed a hint a week later. Practise stating the time and space complexity and the edge cases before you code.
Coding problems
- Count Islands With Diagonal Adjacency (Advanced)
- Minimum Cost to Make a Valid Grid Path (Advanced)
- Dynamic Island Additions (Advanced)
- Minimum Number of Reflections (Advanced)
- Maximum Number of Points With Cost (Advanced)
- Shortest Path Through Maze Keys and Doors (Advanced)
- Walls and Gates Distance (Advanced)
- Minimum Moves to Spread Stones (Advanced)
- Count Negative Values in Sorted Matrix (Advanced)
- Traveling Salesperson With Time Windows (Advanced)
- Swim in Rising Water (Advanced)
- Minimum Obstacle Removal (Advanced)
- Grid Path With Obstacle Eliminations (Advanced)
- Shortest Distance From All Buildings (Advanced)
- Grid Paths Divisible by K (Advanced)
- Longest Increasing Path in a Matrix (Advanced)
- Number of Increasing Paths in a Grid (Advanced)
- Word Search II Count (Advanced)
- Kth Smallest Number in Multiplication Table (Advanced)
- N-Queens Count (Advanced)
- Sudoku Solver (Advanced)
- Unique Paths III (Advanced)
- Count Spanning Trees (Advanced)
- Snake Moves to Reach Target (Advanced)
- Find the Safest Path in a Grid (Advanced)
- Minimum Days to Disconnect Island (Advanced)
- Bricks Falling When Hit (Advanced)
- Rank Transform of a Matrix (Advanced)
- Painting a Grid With Three Different Colors (Advanced)
- Zuma Game (Advanced)
- Max Rectangle Sum No Larger Than K (Advanced)
- Paths With Max Score (Advanced)
- Grid Paths Avoiding Blocked Cells (Advanced)
- Trapping Rain Water II (Advanced)
- Domino and Tromino Tiling Count (Advanced)
- Cherry Pickup Two Robots Down (Advanced)
- Longest Strictly Increasing Path in Grid (Advanced)
- Dungeon Minimum Initial Health (Advanced)
- Maximum Product Path in Grid (Advanced)
- Minimum Cost Grid Path With Direction Signs (Advanced)
- Escape Grid Before Monsters (Advanced)
- Matrix Determinant Modulo Prime (Advanced)
- Matrix Rank Over GF(2) (Advanced)
- Matrix Rank Modulo Prime (Advanced)
- Number of Solutions of Linear System Mod 2 (Advanced)
- Maximum Sum Rectangle in Matrix (Advanced)
- Lights Out Minimum Presses (Advanced)
- Domino Tilings of Three by N Board (Advanced)
- Trace of Matrix Power Modulo (Advanced)
- Lattice Paths Around a Blocked Cell (Advanced)
- Domino Tilings of Three by N (Advanced)
Related
Frequently asked questions
How do I get good at matrix problems?
Practise by level, name the pattern after you solve each problem and review the ones you needed hints for. The list is ordered so you can start with the basic ones.
Can I run matrix problems online here?
Yes. Each problem opens in an editor that runs your code against test cases in Java, Python, C++, Go, JavaScript and more.