Reported October 2024
Amazondynamic programming

Get Max Charge

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 asked this in October 2024, and it's a straightforward optimization problem wrapped in a real-world scenario. You're looking at a greedy or dynamic-programming trap disguised as a charging problem. The OA will test whether you jump to the obvious greedy solution or step back and think about state transitions. StealthCoder sits ready if you blank on the pattern during the live assessment, but knowing the trick now is better.

Pattern and pitfall

Get Max Charge is almost certainly asking you to maximize total charge given constraints on charging rates, time windows, or device states. The common miss: greedy doesn't always work. You might need to track states (which device is charging, at what rate, until when) and use dynamic programming or careful state enumeration. The pattern hinges on recognizing that you can't always charge the highest-demand device first if doing so blocks a better global solution later. StealthCoder will show you the code structure if you're stuck live, but the real win is recognizing early whether this is a state-search problem or a scheduling problem.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Get Max Charge 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. If you're reading this with an OA window open, you're who this was built for.

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. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Get Max Charge FAQ

Is this a greedy problem or DP?+

Greedy looks appealing but often fails. Test your greedy intuition against a small example where charging one device blocks another higher-value charge later. You'll likely find DP or careful state tracking is required. The trick is always 'can I defer this choice for a better payoff'.

What's the actual trick Amazon is testing?+

They want to see if you understand that local optimization (charge this device now) doesn't equal global optimization (maximize total charge). If the problem involves time windows or charging rates, you need to model the decision space and explore it, not just pick greedily.

How do I set up the state space?+

Think about what changes as time progresses or as you make charging decisions. Is it the remaining charge needed per device? The current time? The device currently being charged? Model that explicitly. Build a recursive function or table that answers 'given this state, what's the max charge I can achieve'.

What's a common pitfall I should avoid?+

Assuming you should always charge the device with the lowest current charge or highest demand first. Real-world constraints (time windows, shared chargers, variable rates) mean you often need to explore multiple orderings. Don't lock into greedy without testing.

Can I solve this in 20 minutes if I see it fresh?+

If you recognize the state-space pattern and code DP or recursion cleanly, yes. If you waste 10 minutes defending a greedy solution, no. Know the difference before you sit down. Sketch the state model in 2 minutes, then code.

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