Intermediate Matrix Problems for Coding Interviews
105 intermediate Matrix problems from real coding interviews, each with test cases you can run online. By difficulty they split into 0 basic, 105 intermediate and 0 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
- Pascal Triangle Value (Intermediate)
- Unique Grid Paths (Intermediate)
- Matrix Spiral Order (Intermediate)
- Largest All-Ones Rectangle (Intermediate)
- Largest Island After One Flip (Intermediate)
- Minimum Falling Path Without Repeated Columns (Intermediate)
- Matrix Row and Column Zeroing (Intermediate)
- Shortest Bridge Between Two Islands (Intermediate)
- Minimum Path Sum (Intermediate)
- Unique Paths With Obstacles (Intermediate)
- Shortest Path In Binary Grid (Intermediate)
- Tree Vertical Traversal (Intermediate)
- Count Ways to Tile Board (Intermediate)
- Minimum Cost Path With Portals (Intermediate)
- Minimum Cost to Cut a Board (Intermediate)
- Minimum Cost to Collect All Keys (Intermediate)
- Minimum Number of Buses (Intermediate)
- Minimum Cost to Type a String (Intermediate)
- Find Peak in 2D Grid (Intermediate)
- Median of Row-Wise Sorted Matrix (Intermediate)
- Optimal Matrix Chain Multiplication (Intermediate)
- Vehicle Routing With Capacity (Intermediate)
- A-Star Pathfinding (Intermediate)
- Nonogram Solver (Intermediate)
- Gaussian Elimination Solver (Intermediate)
- Spiral Matrix From Linked List (Intermediate)
- Rotting Oranges (Intermediate)
- Surrounded Regions (Intermediate)
- Pacific Atlantic Water Flow (Intermediate)
- Path With Minimum Effort (Intermediate)
- Snakes and Ladders (Intermediate)
- Distance to Nearest Zero (Intermediate)
- As Far From Land as Possible (Intermediate)
- Number of Enclaves (Intermediate)
- Most Stones Removed (Intermediate)
- Regions Cut by Slashes (Intermediate)
- Number of Closed Islands (Intermediate)
- Maximal Square (Intermediate)
- Out of Boundary Paths (Intermediate)
- Minimum Falling Path Sum (Intermediate)
- Count Square Submatrices (Intermediate)
- Paint N x 3 Grid (Intermediate)
- Word Search (Intermediate)
- Car Pooling (Intermediate)
- Valid Sudoku (Intermediate)
- Rotate Image (Intermediate)
- Range Sum Query 2D (Intermediate)
- Diagonal Traverse (Intermediate)
- Game of Life Step (Intermediate)
- Search a 2D Matrix (Intermediate)
- Search a 2D Matrix II (Intermediate)
- Kth Smallest in a Sorted Matrix (Intermediate)
- Path With Maximum Gold (Intermediate)
- Count Servers That Communicate (Intermediate)
- Detect Cycles in 2D Grid (Intermediate)
- Valid Path Through Street Grid (Intermediate)
- Rolling Ball Maze Reachability (Intermediate)
- Rolling Ball Shortest Distance (Intermediate)
- Coloring a Border (Intermediate)
- Max Increase to Keep City Skyline (Intermediate)
- Count Unguarded Cells (Intermediate)
- Spiral Matrix III (Intermediate)
- Minimum Path Cost in a Grid (Intermediate)
- Minimum Swaps to Arrange a Binary Grid (Intermediate)
- Gold Mine Problem (Intermediate)
- Largest Plus Sign (Intermediate)
- Tile a 3 by N Board With Dominoes (Intermediate)
- Rotating the Box (Intermediate)
- Score After Flipping Matrix (Intermediate)
- Maximum Rows Covered by Columns (Intermediate)
- Minimum Path Sum With One Skip (Intermediate)
- Count Grid Paths Around Obstacles (Intermediate)
- Number of Paths With Even Sum (Intermediate)
- Minimum Falling Path Sum With Diagonal Penalty (Intermediate)
- Monotone Paths Through a Checkpoint (Intermediate)
- Unique Paths With Diagonal Moves (Intermediate)
- Minimum Cost to Traverse Rows With Column Jump Limit (Intermediate)
- Number Spiral Value (Intermediate)
- Count Queen Placements on Blocked Chessboard (Intermediate)
- Digit Removal Game Winner (Intermediate)
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.