O54

Minimum Path Sum Matrix

Mid / Senior Engineer
Target Time: 25 - 35 Minutes
Type: NUMERIC

Problem Statement & Objective

Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path.

Function Signature (Python)

minimum_path_sum_matrix(grid: list[list[int]]) -> int

Input & Output Contract

Output Rule:Minimum yol toplamı.

System Constraints

m == izgara.length, n == izgara[i].length
1 <= m, n <= 200
0 <= izgara[i][j] <= 200

Example Execution Walkthrough

izgara = [[1, 3, 1], [1, 5, 1], [4, 2, 1]]
1 -> 3 -> 1 -> 1 -> 1 toplamı 7 -> cevap: 7

Example Test Scenarios (3)

Example 1
Input:[[[1,3,1],[1,5,1],[4,2,1]]]
Expected Output:7
Example 2: 1+2+3+6 = 12
Input:[[[1,2,3],[4,5,6]]]
Expected Output:12
Example 3: 1x1
Input:[[[5]]]
Expected Output:5
Loading Python Editor...
Input Parameters
[
  [
    [
      1,
      3,
      1
    ],
    [
      1,
      5,
      1
    ],
    [
      4,
      2,
      1
    ]
  ]
]
Expected Output
7