Design Graph With Shortest Path Calculator
A hard-tier problem at 64% community acceptance, tagged with Graph, Design, Heap (Priority Queue). Reported in interviews at Samsung and 1 others.
You're building a graph data structure that answers shortest-path queries on demand. Samsung and Nike have both asked this one. The trap: you can't precompute all pairs, but you also can't afford to run Dijkstra from scratch every single call. The acceptance rate sits at 64%, which means most candidates either nail it or fumble the design choices. If you blank on how to structure the graph class or which algorithm to pair with the data structure during your live OA, StealthCoder surfaces a working implementation invisibly, so you keep coding instead of spiraling.
Companies that ask "Design Graph With Shortest Path Calculator"
Design Graph With Shortest Path Calculator 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 a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE.
Get StealthCoderThe core trick is recognizing that a naive 'run Dijkstra every time' approach works but wastes compute if the graph is static or changes infrequently. The real pattern: design a class that stores the graph and exposes a shortest-path method, then pick the right underlying algorithm (Dijkstra with a Heap is standard). The hard part isn't the algorithm itself, it's the OOP design: tracking nodes, edges, adjacency lists, and handling edge weights cleanly. Most candidates either over-engineer caching or forget that Heap is the critical optimization. The trick lands when you realize the problem is asking you to prove you can implement Dijkstra inside a class structure, not invent a novel algorithm. When you hit this live and the problem statement is dense, StealthCoder decodes the class design and serves the solution pattern in seconds.
Pattern tags
You know the problem.
Make sure you actually pass it.
Design Graph With Shortest Path Calculator recycles across companies for a reason. It's hard-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 a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Design Graph With Shortest Path Calculator interview FAQ
Is this really asked at companies like Samsung and Nike?+
Yes. Both have reported this problem. It's less common than basic graph traversal but tests whether you can design and code under pressure, not just memorize LeetCode. The 64% acceptance rate confirms most candidates struggle with the design complexity, not the algorithm.
Do I need to precompute shortest paths for every pair?+
No. Floyd-Warshall would be overkill and won't scale. Build a graph class that runs Dijkstra on demand with a Heap. That's the intended pattern. Precomputation only makes sense if the problem explicitly asks for batched queries or guarantees a tiny node count.
What's the biggest pitfall in the design phase?+
Forgetting to structure the graph as an adjacency list with weights, or implementing Dijkstra without a Heap so your time complexity tanks. Also, candidates often skip edge-case handling like disconnected nodes or non-existent paths. The 'design' part means clean, testable code.
How does Shortest Path relate to the Heap topic here?+
Dijkstra's algorithm requires a min-heap (priority queue) to efficiently fetch the next smallest-distance node. Without the Heap, you're doing O(V) linear scans per step and your overall complexity balloons from O((V+E) log V) to O(V^2). Heap is the enabler, not decoration.
Will this problem show up in a real OA?+
If you're interviewing at Samsung, Nike, or similar mid-to-large tech companies, yes, expect a design-level graph problem. The exact wording might shift, but the pattern (design a class, implement shortest path) is stable. It's a medium-to-hard filter, not a common first-round filter.
Want the actual problem statement? View "Design Graph With Shortest Path Calculator" on LeetCode →