Dsa
Dynamic Programming
Easy
Minimum Path Sum
You are given a grid (2D list) of non-negative integers, where each cell represents the cost of stepping into that cell. You need to find a path from the top-left corner to the bottom-right corner that minimizes the total cost of this path. You can only move either down or right at any point. Write a program that reads input and prints the minimum path sum.
Input format:
- The first line contains two integers m and n (1 <= m, n <= 100) - the number of rows and columns.
- The next m lines contain n integers each, representing the grid.
Output format:
- A single integer representing the minimum path sum.
Example:
Input:
3 3
1 3 1
1 5 1
4 2 1
Output:
7
Key concepts
dynamic_programming2d_arrays
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