Find Max Distinct Items
Reported by candidates from IBM's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
IBM's March 2024 assessment hit candidates with a deceptively simple problem: find the maximum number of distinct items. Sounds like a one-liner until you realize the catch. The OA is testing whether you understand the actual constraint hiding in the problem statement. Most candidates misread it, jump to a hash set, and leave marks on the table. StealthCoder catches that misread the moment you see the full prompt and flags the real ask. You've got 24-48 hours to nail the pattern.
Pattern and pitfall
Without the full problem text, the pattern is likely counting or hash-table based, but the trick always lives in the constraint. Is it about selecting items up to a weight limit. Finding distinct items in a stream. Maximizing variety under a budget. The surface solution is hash-set cardinality. The real solution requires you to read the constraint carefully, then apply greedy logic or dynamic programming to maximize the count. Most OA failures on this problem come from solving the wrong problem, not the algorithmic part. When you hit the live OA, StealthCoder reads the exact constraint and surfaces the real requirement. That's your hedge if the wording trips you up under time pressure.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Find Max Distinct Items 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 StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass IBM's OA.
IBM 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 Max Distinct Items FAQ
Is this just a hash set problem?+
It looks like one, but no. Hash sets count distinct items trivially. IBM's version has a constraint (weight, cost, or selection rule) that forces you to choose which distinct items to keep. Read the full constraint before you code.
Will this problem ask me to optimize or just count?+
Almost certainly optimize. You're finding the maximum distinct items under some limit. That's greedy or DP territory. Just counting distinct items is too easy for an IBM OA.
What's the gotcha on this one?+
Candidates assume they can take all distinct items. The real problem restricts your selection. You have to choose a subset of distinct items that satisfies the constraint and maximizes the count. Misreading that costs most people.
How much time should I spend on the problem statement?+
At least 2-3 minutes reading and annotating the constraint. This problem punishes fast readers. The algorithm is usually simple once you know the real ask. Spending time upfront saves you a rewrite.
Is this pattern still asked in 2024?+
Yes. Counting and optimization under constraints are core to IBM's technical screens. March 2024 confirms it. Expect it to show up again. The variant changes, the core pattern doesn't.