Medium · Dynamic Programming

Minimum Path Sum

Given an m × n grid of non-negative integers, return the minimum sum of the values along a path from the top-left cell to the bottom-right cell that moves only right or down.

Examples

Example 1

[[1,3,1],[1,5,1],[4,2,1]]

Output: min sum 7

Example 2

[[1,2,3],[4,5,6]]

Output: min sum 12

Rebuild it in the studio

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Dynamic Programming problems