Reported May 2024
Amazongreedy

Find Max Pairs

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 2024 OA included a pairing problem with minimal setup and a deceptively simple constraint. You're given a collection of elements and need to find the maximum number of pairs that can be formed. The trick isn't the pairing logic itself. It's recognizing that the optimal strategy often depends on sorting or frequency analysis, not simulation. If you blank on the exact approach during the live OA, StealthCoder will read the problem and hand you the pattern in seconds so you don't waste 20 minutes guessing.

Pattern and pitfall

Max pairing problems typically hinge on greedy selection or frequency counting. If the elements have values, sort them and pair greedily from one end. If it's a frequency problem, count occurrences and pair identical or compatible elements. The common pitfall is overthinking the constraints. Candidates often try dynamic programming or complex state machines when a single pass and a counter will do. The OA format tests whether you can spot the pattern fast and code it clean under pressure. StealthCoder acts as a safety net here: if you freeze on whether to sort or count first, it will show you the exact approach so you can execute without panic.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Find Max Pairs 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 would have shipped this the night before his JPMorgan OA if he'd had it.

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. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find Max Pairs FAQ

Is this a frequency-counting problem or a sorting problem?+

Usually both. Count frequencies first, then determine the pairing rule based on the constraint. If you're pairing identical elements, divide the count by 2. If you're pairing compatible elements, you may need to sort by value or frequency. Read the constraint carefully.

What's the most common mistake on pairing problems?+

Overcomplicating the selection order. Candidates implement DP or recursion when a greedy approach works. Sort once, iterate once, count pairs. If the problem allows pairing any two elements, the answer is often just array length divided by 2.

How do I know if I need a hash map or a sort?+

If the problem asks for pairs of identical elements or specific values, use a hash map to count frequencies. If it asks for pairs within a range or with a specific relationship, sort first. Read for the word 'any' or 'compatible'.

Can I solve this in one pass?+

Sometimes. Frequency counting is one pass. Sorting is O(n log n), not one pass. If you're allowed to modify the array, you might skip the hash map. Always optimize for clarity and correctness first, speed second.

What should I verify before submitting?+

Test with edge cases: empty array, single element, all identical elements, no valid pairs. Confirm the pairing constraint. Make sure your count doesn't double-pair an element. Walk through a small example by hand.

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