The Find Shortest Path with K Hops interview question is a graph optimization problem. You are given a weighted graph and a target number of "hops" . In this version, a "hop" allows you to traverse any edge for a cost of 0. Your goal is to find the minimum distance from a source to a destination using at most such hops.
Goldman Sachs asks the Find Shortest Path coding problem to see if you can adapt standard pathfinding algorithms like Dijkstra to include an extra "resource" or "budget." It evaluations your ability to expand the state space of an algorithm—moving from "shortest distance to node " to "shortest distance to node using hops."
This is solved using Modified Dijkstra's Algorithm.
(distance, node, hops_remaining).u with hops_remaining = j:
v with cost . New state: (dist + W, v, j).v with cost 0. New state: (dist, v, j - 1).minDist[node][hops_remaining] to prune paths.Path: A --(10)--> B --(20)--> C, .
When an algorithm has a "budget" (like skips, stops, or hops), the budget almost always becomes a second dimension in your visited/distance array and your Priority Queue state. This is a high-signal Graph interview pattern.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Minimum Weighted Subgraph With the Required Paths | Hard | Solve | |
| Modify Graph Edge Weights | Hard | Solve | |
| Reachable Nodes In Subdivided Graph | Hard | Solve | |
| Minimum Cost to Reach City With Discounts | Medium | Solve | |
| Minimum Cost Path with Edge Reversals | Medium | Solve |