Example
Input
min_path_sum([[1,3,1],[1,5,1],[4,2,1]])
Output
7
One minimum path is 1 → 3 → 1 → 1 → 1 (sum = 7).
Full lesson preview
Compute the smallest sum along a path from top-left to bottom-right of a grid moving only right or down.
Problem statement
Task
Examples
Input
min_path_sum([[1,3,1],[1,5,1],[4,2,1]])
Output
7
One minimum path is 1 → 3 → 1 → 1 → 1 (sum = 7).
Input format
Output format
Constraints
Samples
Input
min_path_sum([[1,2],[3,4]])
Output
7
Path 1 → 2 → 4 gives sum 7.