Minimum Path Sum
Updated
Problem statement
Given a nonempty rectangular matrix grid of nonnegative integers, start at the top-left cell and reach the bottom-right cell.
At each step, move exactly one cell right or one cell down. Return the minimum possible sum of the values on the path, including both endpoints.
Function
minimumPathSum(grid: int[][]) → intExamples
Example 1
grid = [[1,3,1],[1,5,1],[4,2,1]]return = 7The path 1, 3, 1, 1, 1 has sum 7.
Example 2
grid = [[1,2,3],[4,5,6]]return = 12Moving right, right, then down gives 1 + 2 + 3 + 6.
Constraints
1 <= grid.length, grid[0].length <= 500- Every row has the same length.
0 <= grid[r][c] <= 10000- The answer fits in a signed 32-bit integer.
More Goldman Sachs Phone Screen questions
- Best Average Student ScorePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Design Hash MapOA · PHONE SCREEN · Seen Nov 2026
- House Robber IIIPHONE SCREEN · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · Seen Nov 2026
- Check a Complete Binary TreePHONE SCREEN · Seen Oct 2026
- Meeting RoomsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Count Staircase WaysPHONE SCREEN · Seen Oct 2026
- Is a Power of TenPHONE SCREEN · Seen Oct 2026
- Minimum Traveling Salesperson TourPHONE SCREEN · Seen Oct 2026
- Square Root with Newton IterationPHONE SCREEN · Seen Oct 2026
Similar questions at other companies
- Find Robots by Blocker DistancesUber · PHONE SCREENUber interview questions
- Factory Cost — Minimum Cost Across StagesStripe · PHONE SCREENStripe interview questions
- Path Through an O/X Grid Using Only Right and DownAmazon · PHONE SCREEN
- Maximal SquareAirwallex · PHONE SCREENAirwallex interview questions
- Maximal SquareSalesforce · PHONE SCREENSalesforce interview questions
- Minimum Path SumBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Maximum Falling Path SumIMC Trading · PHONE SCREENIMC Trading interview questions
- Grid Paths Around Blocked CellsAdobe · PHONE SCREENAdobe interview questions
- Largest Diamond of Ones in a GridRippling · PHONE SCREENRippling interview questions
- Longest Increasing Path in a MatrixNew Relic · PHONE SCREEN · ONSITE INTERVIEW