Reported January 2025
Amazondynamic programming

Min Energy Cost

Reported by candidates from Amazon's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Amazon OA. Under 2s to a working solution.
Founder's read

Amazon hit you with Min Energy Cost in January 2025, and you've got hours to figure out what they're actually testing. Energy cost problems usually hide a graph or dynamic programming trick under a thin physics wrapper. The real challenge isn't the math, it's spotting whether you're supposed to find a shortest path, optimize a sequence of choices, or compute a minimum spanning tree. StealthCoder sits quiet during your OA and surfaces the pattern the moment you blank on whether this is Dijkstra or DP.

Pattern and pitfall

Min Energy Cost typically asks you to move between states (nodes, positions, or configurations) while minimizing cumulative cost. The trap is mistaking it for greedy when it demands DP, or missing that it's actually a weighted graph problem. You'll likely need to track minimum cost to reach each state, which screams either Dijkstra's algorithm or dynamic programming with memoization. The common pitfall is trying to make a greedy choice at each step without considering future costs. Build a state transition model first, identify your recurrence, then code. If the problem mentions multiple paths or stages, DP is your first guess. If it's about distance or shortest route, lean Dijkstra. StealthCoder catches the moment you lock into the wrong approach and resets your thinking before you code yourself into a corner.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Min Energy Cost cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Amazon's OA.

Amazon reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Min Energy Cost FAQ

Is this problem greedy or DP?+

Greedy rarely works for Amazon cost-minimization problems. Build a small example and trace both approaches. If making the cheapest choice now forces a worse path later, it's DP or shortest-path. Test with three or four steps to see the pattern.

How do I set up the state space?+

Identify what changes as you move: position, time, energy level, or configuration. Each unique combination is a state. Then define the transition cost between states. That's your recurrence relation or graph edge. Write it out on paper first.

Should I use Dijkstra or BFS with DP?+

Dijkstra if edge weights vary and you're finding true shortest path. DP with memoization if you're optimizing over sequences or choices. If all transitions cost the same, BFS is enough. Check the problem constraints.

What's the most common mistake candidates make?+

Assuming a local greedy choice works globally. Also, forgetting to track visited states in DP to avoid cycles or recomputation. Test your solution on the examples carefully before submitting.

Can I solve this in 48 hours if I've never seen it?+

Yes. Study one shortest-path problem (Dijkstra) and one DP minimization problem tonight. Recognize the pattern from the problem description tomorrow, then code it. That's 80 percent of the fight.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Amazon.

OA at Amazon?
Invisible during screen share
Get it