Dsa
Matrix
Warm-up
Matrix Minimum Path Sum
Given a two-dimensional grid of integers, where each integer represents the cost to enter that cell, compute the minimum cost required to move from the top-left corner to the bottom-right corner of the grid. You can only move either down or right at any point in time.
Input format:
- The first line contains two integers M and N, the dimensions of the grid.
- The next M lines contain N integers each, representing the grid.
Output format:
- Print the minimum path sum.
Example:
Input:
3 3
1 3 1
1 5 1
4 2 1
Output:
7
Key concepts
matrixpathfindingdynamic programming
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now