Reported January 2024
Ciscogreedy

Maximum Chocolates from Jars

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

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

Cisco asked this in January 2024, and it's a setup that catches people off guard. You've got jars of chocolates with some constraint (the exact constraint matters here), and you need to maximize what you take. The pattern isn't immediately obvious from the title, but it's either greedy or simulation. No one expects to blank on a chocolate problem, so if you do, StealthCoder reading the full problem statement in real time is your safety net. You'll know the trick the moment you see the full constraints.

Pattern and pitfall

Without the full problem text, the likely play is greedy. Typically in 'maximize from jars' problems, you're either picking greedily by largest value, or there's a trick rule that forces simulation (like 'you can't take from adjacent jars' or 'taking depletes neighbors'). Cisco tends toward constraint-based puzzles that reward careful reading over algorithmic complexity. The pattern is most likely greedy with a hidden rule that changes the strategy. If you blank on the greedy approach, StealthCoder will show you the constraint you missed and the correct simulation loop. This is the kind of problem where 20 seconds of clarity beats 10 minutes of wrong direction.

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 Maximum Chocolates from Jars 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 Cisco's OA.

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

Maximum Chocolates from Jars FAQ

Is this a DP problem or greedy?+

Almost certainly greedy with a trick. DP gets you partial credit. Read the constraints on the jars first (are they ordered, can you skip, do jars interact). The trick rule is what separates right from wrong. Greedy usually wins once you see it.

What's the common mistake candidates make?+

Greedy-ing without reading the full constraint. Many assume you can pick any jar freely. Cisco almost always adds a rule: adjacent jars, minimum/maximum picks, or a per-jar cooldown. Miss that, your solution fails all test cases.

How do I approach this in 30 minutes?+

Spend 5 minutes reading the constraint. Draw one example with your constraint. Then code. Don't optimize early. A working simulation beats a broken greedy every time. Test your example by hand first.

Will the jars be given as an array?+

Almost certainly. Input is likely an array of chocolate counts and maybe a budget or limit. Parse the input format carefully. Off-by-one errors kill these problems fast.

Is this actually hard or does it feel harder than it is?+

It feels harder because the title is vague. Once you see the full problem and the constraint, it's medium at worst. Cisco's OA is more about reading comprehension than algorithm difficulty. You've got this.

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

OA at Cisco?
Invisible during screen share
Get it