Minimum Path Sum

Given an m x n grid filled with non-negative numbers, find a path from the top-left corner to the bottom-right corner which minimizes the sum of all numbers along its path. You can only move either down or right at any point in time.

Constraints

  • m == grid.length
  • n == grid[i].length
  • 1 <= m, n <= 200
  • 0 <= grid[i][j] <= 200
Saving… · 2 lines
class Solution:
def minPathSum(self, grid: List[List[int]]) -> int:
Console

Click Run to execute sample tests.