Reported August 2024
Akunadynamic programming

Get Max Cost

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

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

Akuna's August 2024 OA included Get Max Cost, a problem that catches candidates who jump straight to brute force. You're looking at an optimization problem where naive recursion or nested loops will timeout. The trick is recognizing that you're choosing items with constraints, and the answer lives in dynamic programming or greedy logic. If you blank on the pattern mid-assessment, StealthCoder reads the problem live and surfaces the approach so you don't lose 20 minutes to panic.

Pattern and pitfall

Get Max Cost is almost certainly a resource allocation or knapsack-adjacent problem. Candidates report either a capacity constraint (weight, cost, or count limit) and you're maximizing value, or a selection rule where each choice cascades into the next. The gotcha: greedy sorting by one dimension (highest cost first, or best ratio first) works for some test cases and fails silently on others. The real solution is DP state building or constraint-aware greedy. Most timeouts come from recalculating the same subproblems. StealthCoder's value during the live OA is catching whether you need memoization or a different state transition before you burn 30 minutes on the wrong path.

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 Get Max 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 Akuna's OA.

Akuna 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.

Get Max Cost FAQ

Is this a knapsack variant?+

Likely. If the problem says you have a budget or limit and want to pick items to maximize cost or value, it's knapsack territory. Even if it doesn't feel like the textbook version, the DP skeleton (state = what you've used so far, transition = include or exclude) usually applies.

Will greedy sorting work?+

Not reliably. Greedy (e.g., sort by cost-to-weight ratio and pick highest first) passes examples but fails hidden test cases. Build a DP table or think through the constraint more carefully. Test greedy logic against a small counter-example before submitting.

What if the problem has multiple constraints?+

Multi-dimensional DP. Two constraints means a 2D table (or higher). It's slower but correct. O(n * limit1 * limit2) is reasonable for n under 500 and limits under 10k. Check memory and time explicitly before coding.

How do I spot if it's a simulation instead of DP?+

If the problem describes a process or iteration (do X, then based on result do Y), it might be simulation. Simulate one or two steps by hand. If you see repeating substructure (same choice branching from multiple states), it's DP. If it's pure step-by-step logic, simulate.

How much time should I spend recognizing the pattern?+

2-3 minutes max. Skim the problem, identify the constraint and the goal. Write a brute force sketch. If it's obviously exponential, pivot to DP or greedy. Don't overthink it. You have a clock.

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

OA at Akuna?
Invisible during screen share
Get it