FastPrepMaximum Gold Path
Problems/Maximum Gold Path

Maximum Gold Path

GoTo logoGoTo● EasyNEW GRADOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

You are given a 2D integer grid grid, where each cell contains some amount of gold.

You may start from any cell in the first column. From a cell (row, col), you may move to one of the following cells in the next column:

  • (row, col + 1)
  • (row - 1, col + 1)
  • (row + 1, col + 1)

Return the maximum total gold you can collect by following a valid path from the first column to the last column.

Function

maxGoldPath(grid: int[][]) → int

Examples

Example 1

grid = [[1,3,3],[2,1,4],[0,6,4]]return = 12
grid
012013312142064

One optimal path is 2 -> 6 -> 4, collecting total gold 12.

Constraints

  • 1 <= grid.length
  • 1 <= grid[i].length

Similar questions at other companies

  • Maximum Remaining Drone PowerAkuna Capital · OAAkuna Capital interview questions
  • Matrix TraversalFlexport · OAFlexport interview questions
  • Cherry PickupInfosys · OAInfosys interview questions
  • Safest Shortest Path Through a GridSnowflake · OASnowflake interview questions
  • Minimum Cost Path with TeleportationsAmazon · OA
  • Grid Paths with Override PassesIMC Trading · OAIMC Trading interview questions
  • Largest Square of OnesOpenAI · OAOpenAI interview questions
  • Grid Paths with Override PassesMicrosoft · OAMicrosoft interview questions
  • Minimum Moves to Spread Stones Across a GridAmerican Express · OAAmerican Express interview questions
  • Minimum Starting Health in a GridIntuit · OAIntuit interview questions
See GoTo hiring insights
Saved
class Solution {
    public int maxGoldPath(int[][] grid) {
      // write your code here
    }
}
Checking account…