FastPrepMaximum-Value Grid Path
Problems/Maximum-Value Grid Path

Maximum-Value Grid Path

Goldman Sachs logoGoldman Sachs● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A recovered Goldman Sachs screening report asks for the maximum value a robot can collect while moving from the top-left to the bottom-right of a grid. It does not give the allowed moves, what happens on a non-square grid, or the limits. This version only allows moves right or down. Our version is about 84% the same as the reported question.

Given a nonempty rectangular integer matrix grid, start at its top-left cell and reach its bottom-right cell by moving only one cell right or one cell down.

Collect the value of every visited cell, including both endpoints. Return the maximum total value of a valid path.

Function

maximumGridPathValue(grid: int[][]) → long

Examples

Example 1

grid = [[5,1,2],[4,0,3],[2,7,1]]return = 19
grid
012051214032271

The path 5,4,2,7,1 has total 19.

Example 2

grid = [[-1,-2],[-3,-4]]return = -7
grid
010-1-21-3-4

Moving right then down gives -1-2-4=-7.

Constraints

  • 1 <= grid.length, grid[i].length <= 1000
  • All rows have the same length.
  • -10^9 <= grid[i][j] <= 10^9
  • The answer fits in a signed 64-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
All Goldman Sachs interview questionsSee Goldman Sachs hiring insights
Saved
class Solution {
    public long maximumGridPathValue(int[][] grid) {
      // write your code here
    }
}
Checking account…