MEDIUMasked at 1 company

Path with Maximum Gold

A medium-tier problem at 68% community acceptance, tagged with Array, Backtracking, Matrix. Reported in interviews at Geico and 0 others.

Founder's read

Path with Maximum Gold is a medium backtracking problem that looks deceptively simple until you realize the greedy approach fails. You're given a grid of cell values and need to find a path that collects the maximum gold without revisiting cells. Geico has asked this one. The acceptance rate sits at 68%, which sounds high until you hit the live OA and realize you need to properly explore all possible paths instead of just chasing the biggest adjacent cell. This is exactly the kind of problem where a moment of confusion costs you time you don't have. If you blank on the backtracking setup or the visited-cell tracking, StealthCoder surfaces a working solution in seconds, invisible to the proctor.

Companies asking
1
Difficulty
MEDIUM
Acceptance
68%

Companies that ask "Path with Maximum Gold"

If this hits your live OA

Path with Maximum Gold is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too.

Get StealthCoder
What this means

The trick is recognizing this is an exhaustive path-exploration problem, not an optimization-by-greed problem. You need backtracking to explore every possible path from every starting cell, tracking visited cells locally during recursion and unmarking them on backtrack so other paths can use those cells. Most candidates either try to use dynamic programming (doesn't work because the visited constraint changes the subproblem definition) or implement backtracking but forget to properly restore the visited state. The algorithm walks through each cell, tries all four directions recursively, marks the cell as visited before recursion, collects the maximum, then unmarks it. Array iteration and Matrix traversal are straightforward, but the backtracking discipline is where mistakes live. If you've practiced this pattern on similar matrix-exploration problems, it clicks fast. If you haven't, the state-management details will trap you under time pressure. StealthCoder is the hedge if the backtracking pattern doesn't land during the live assessment.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Path with Maximum Gold recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Path with Maximum Gold interview FAQ

Why doesn't greedy work on this problem?+

Greedy picks the largest adjacent cell at each step, but optimal paths often backtrack or take detours through smaller cells to reach larger clusters. You must explore all possible paths, not just the locally best one. This is why backtracking is required, not a shortcut.

How do I avoid revisiting cells without breaking other paths?+

Mark the cell as visited before recursing into neighbors, then unmark it after the recursive call returns. This way, other recursive branches can still use that cell. It's the core of backtracking: explore, restore, repeat.

Is this still asked at major companies?+

Geico has confirmed asking it. The acceptance rate of 68% suggests it's not rare, but it's common enough that you should drill the backtracking pattern. If you see a matrix with path constraints, assume backtracking.

What's the time complexity and does it matter for the OA?+

Worst case is exponential in grid size because you explore all paths. For typical OA grids (9x9 or smaller), this is acceptable. Optimizations exist, but correctness first. Focus on a clean backtracking implementation that passes examples.

Should I start from every cell or just corners?+

Try every cell as a starting point. The maximum gold path doesn't have a fixed start. Iterate the grid, call backtracking from each cell, and track the global maximum across all runs.

Want the actual problem statement? View "Path with Maximum Gold" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.