Reported August 2024
Amazoncounting

Get Num Teams

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 August assessment included a problem on counting team compositions from a candidate pool. This is a classic combinatorics question wrapped in a hiring scenario: given a list of skill levels or experience ratings, count how many valid three-person teams can be formed under some constraint (usually an ordering or ratio rule). The trap is assuming brute force will pass. It won't. You need to recognize the pattern and optimize.

Pattern and pitfall

The problem likely asks you to count triplets (i, j, k) where i < j < k and the values at those indices satisfy a specific ordering: either ascending (arr[i] < arr[j] < arr[k]) or descending (arr[i] > arr[j] > arr[k]). Brute force is O(n^3) and will time out on large inputs. The insight is that for each middle index j, you can precompute how many elements to the left are smaller (or larger) and how many to the right are larger (or smaller), then multiply. That's O(n) space and O(n) time after sorting or preprocessing. StealthCoder can feed you the full solution pattern in seconds if you blank during the live OA, removing the risk of a timeout penalty.

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 Get Num Teams 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.

Get Num Teams FAQ

Is this a sorting problem or a counting problem?+

It's counting, but you'll likely optimize using a left-to-right scan with precomputed counts. No sorting required unless the problem specifies values are unsorted. The O(n) solution scans each middle element once and tracks constraints on both sides.

What's the most common pitfall?+

Jumping straight to triple nested loops. You'll hit time limits. The trick is fixing the middle element and counting valid left-right pairs in linear time. Candidates who skip this optimization fail silently.

Do I need to worry about indices vs values?+

Yes. The constraint is usually on index order (i < j < k) and value order simultaneously. Make sure you're comparing arr[i], arr[j], arr[k], not indices. Off-by-one or index confusion is common.

Can I solve this in 48 hours without prep?+

If you know the pattern: iterate middle, count left and right in one pass. If you don't, brute force fails. Recognize it's a precomputation problem, not a DP or graph problem. That mental shift matters more than coding speed.

Will this problem appear again in Amazon's pipeline?+

Yes. Amazon repeats variations of counting and combinatorics problems. Once you nail the left-right precomputation pattern, you own a whole class of Amazon OA questions.

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