Reported May 2025
Amazondynamic programming

Find Maximum Score

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's May 2025 OA included Find Maximum Score, a problem that looks simple until you realize the greedy intuition doesn't work. You're likely given an array and asked to maximize some cumulative value based on choices or operations. This is a classic setup where the obvious move fails, and you need to think about state transitions instead. StealthCoder can save you if the pattern doesn't click in the first 90 seconds.

Pattern and pitfall

Find Maximum Score almost always boils down to dynamic programming or a constrained greedy choice. The trap is assuming you can always pick the locally optimal option. In reality, you're tracking whether the total score is better by taking path A or path B at each step, and the decision depends on what came before. The pattern usually involves either DP state like max_score[i] = best outcome up to position i, or recognizing that you can't revisit elements, forcing you to choose wisely. During the live OA, if you can't articulate the state in 2 minutes, StealthCoder will show you the clean DP frame so you can code instead of whiteboard.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Find Maximum Score 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. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as house robber. If you have time before the OA, drill that.

⏵ The honest play

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

Amazon reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find Maximum Score FAQ

Is this a DP problem or greedy?+

It's DP disguised as greedy. Greedy fails because later choices invalidate earlier ones. You need to track the maximum score achievable at each decision point, comparing paths. Set up a DP table or memoized function that stores the best outcome from each position onward.

What's the main pitfall Amazon candidates hit?+

Assuming you can always take the highest immediate gain. The gotcha is that picking one option often blocks or changes the value of future options. Read the constraints carefully. If you can't use an element twice or must respect some ordering, that's your DP boundary.

How do I set up the state in 3 minutes?+

Define dp[i] as the max score achievable considering elements up to index i. Then decide: do I take element i or skip it? Compare dp[i-1] (skip) vs dp[i-2] + score_with_i (take, accounting for any penalty or rule). Fill the table bottom-up.

Are there any common optimizations?+

Space optimization: if your DP only depends on the last two states, use two variables instead of an array. Time is usually O(n) or O(n^2) depending on how many options branch from each step. Check if you're doing redundant work in nested loops.

Should I worry about overflow or edge cases?+

Yes. Test n=1 (answer should be the single element or 0 depending on rules), and check if negative scores are possible. If so, ensure your base case initializes correctly. Integer overflow is less likely in Python, but in Java or C++ watch your accumulator.

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