DDSA Solutions

Matrix

79 problems · 45 with full explanations

6 Easy25 Medium16 Hard
Matrix problems often involve BFS/DFS flood fill, dynamic programming on 2D grids, or spiral/diagonal traversal. For row × column DP, break it into 1D sub-problems column by column. Common pitfalls: boundary checks and modifying the input matrix in-place.

How to practice

To practice Matrix problems effectively, start with the Easy problems listed below, trace through each solution on paper, then re-implement without looking. When you can recognise the matrix pattern within 30 seconds of reading a new problem, move on to Medium difficulty. Use the related topic pages and our study guide for a structured progression.

Open the full study guide →

Start here (Easy + explained)

All Matrix problems