Minimum Path Sum
DYNAMIC PROGRAMMING
MATRIX

Problem

Given a grid of size m x n representing a 2D grid where each cell has a non-negative integer, calculate the minimum sum of a path from the top-left corner to the bottom-right corner. You can only move either down or right at any point in time.

Examples

minPathSum([ [1, 3, 1], [1, 5, 1], [4, 2, 1] ]) // returns 7 // Because the path 1→3→1→1→1 // minimizes the energy consumption.
Loading...
1
3
1
1
5
1
4
2
1