Reported January 2024
Amazonhash table

Get Discount 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 "Get Discount Pairs" hit the OA circuit in January 2024, and candidates are blanking on the pattern. You're looking at a pairing problem where you need to find combinations of items that satisfy some discount condition, likely involving a cost threshold or matching criterion. The trick is almost always either a hash-table lookup for fast pairing or a two-pointer scan if the input is sorted. StealthCoder sits invisible during the live test, ready to surface the pattern the moment you see the actual constraints.

Pattern and pitfall

Without the full problem text, the standard move for Amazon discount-pair questions is a hash-table approach: iterate through prices, store them in a map with their indices or frequencies, then for each item check if its complement (or match) exists. If it's sorted input, two-pointers from both ends is faster. The gotcha is always the counting: do you count unique pairs, do you allow reuse, what about ties. Amazon loves boundary cases and off-by-one errors in pair counting. When you're live and the problem is on screen, StealthCoder will read it and show you whether this is a hash-table scan or a sorted two-pointer problem in seconds.

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 Discount 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 passed his OA cold and still thinks the filter is broken.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as two sum. If you have time before the OA, drill that.

⏵ 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 passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Get Discount Pairs FAQ

Is this a hash-table problem or sorting problem?+

Likely hash-table if you need to find pairs in unordered input fast. Sorting plus two-pointers if the problem asks for the pair closest to a target or for all pairs in sorted order. Amazon usually accepts both, but hash-table is the safety net for time limits.

What's the most common pitfall candidates hit?+

Miscounting pairs when duplicates exist, or including the same element twice when you shouldn't. Also forgetting to handle the case where two items have the same price or identifier. Check your loop bounds and make sure you're not double-counting.

Do I need to return pairs in a specific format?+

Almost always yes. Amazon typically wants pairs as tuples, indices, or as a count. Re-read the output spec in the problem statement carefully. That's where half the wrong submissions come from.

How long should this take me to code live?+

Fifteen to twenty minutes if the pattern is clear and you're not overthinking. Hash-table solution is usually 10-15 lines. If you're stuck, that's the sign to use StealthCoder or sketch pseudocode and come back to it.

Is this problem still asked at Amazon in 2024?+

Yes. Pairing and matching problems are evergreen at Amazon because they test hash-tables and two-pointers, both core to their interview bar. Don't skip learning the pattern.

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