Reported September 2024
Amazongreedy

Get Max Information Gain

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 September OA included a problem called 'Get Max Information Gain.' You're looking at an optimization problem that hinges on understanding what 'information gain' means in context, usually tied to decision trees or entropy calculations. The trap is overthinking the formula. Most candidates blank because they assume it's complex math when it's often a simulation or greedy selection of the best split. StealthCoder reads the exact problem statement and feeds you the pattern in real time if you get stuck on the definition.

Pattern and pitfall

Information gain problems typically ask you to maximize the reduction in entropy when splitting a dataset. The algorithm is usually greedy: iterate through candidate splits, calculate the gain for each, and pick the maximum. The pitfall is misunderstanding what 'gain' means in the problem's specific context. Some versions ask you to return the split point, others the numerical gain. You'll need to compute weighted entropy before and after a split, then diff them. If you lock up on the formula during the live OA, StealthCoder surfaces the exact calculation you need in seconds, letting you code with confidence instead of guessing.

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 Get Max Information Gain 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

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

Get Max Information Gain FAQ

Is this a machine learning problem or pure algorithm?+

It's algorithm. You don't need ML theory. You need to compute entropy (or a gain metric) for splits in a dataset. Think of it as a simulation where you try each split and score it numerically. The pattern is greedy: find the split that maximizes gain.

What's the common pitfall Amazon candidates hit?+

Confusing entropy formulas or using the wrong weighting. Candidates often forget to weight the child entropies by their sizes, or they misread what constitutes a valid split. Read the problem's exact definition twice before coding.

How do I prepare for this in 24 hours?+

Understand entropy: sum of (p * log(p)) for each class. Know how to calculate weighted entropy of children after a split. Practice one split calculation by hand. Then code the loop that tries all splits and returns the best.

Do I need to handle ties or edge cases?+

Almost certainly. What happens if all splits give equal gain? What if there's only one split point? Re-read the problem's output spec carefully. Amazon usually wants a specific index or value, not just the gain.

Is this still asked by Amazon in late 2024?+

Yes. Information gain and decision tree concepts show up regularly in Amazon OAs. The exact problem wording changes, but the pattern holds. Expect similar problems in the future.

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