Reported March 2024
Trade Deskhash table

Buddies Greater Than Target

Reported by candidates from Trade Desk's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Trade Desk OA. Under 2s to a working solution.
Founder's read

Trade Desk hit you with Buddies Greater Than Target in March, and it's a counting problem that looks deceptive on first read. The title makes it sound like a graph traversal or relation thing. It's not. You're counting pairs or elements that satisfy a threshold condition, and the real win is doing it efficiently without nested loops that timeout. StealthCoder will catch you if you blank on the optimization, but understand the pattern now and you won't need it.

Pattern and pitfall

The core trick: this is a hash-table or two-pointer counting problem. You're iterating through a data set, comparing elements to a target value, and tallying matches. The naive approach times out because you iterate every element against every other element. The pattern is to precompute or use a hash map to track frequencies, then count valid pairs in one or two passes. If the data is sorted, two pointers from opposite ends works too. The gotcha is assuming you need to track relationships or simulate anything. You don't. It's pure counting logic with the right data structure. StealthCoder handles the edge cases if you freeze, but the algorithm itself is clean once you see it.

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 Buddies Greater Than Target 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

⏵ 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 Trade Desk's OA.

Trade Desk 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.

Buddies Greater Than Target FAQ

Is this actually a graph problem?+

No. The title is misleading. There's no traversal, no edges, no shortest path. It's a counting problem that uses a hash table or sorted array. Treat 'buddies' as just another word for 'elements that meet a condition'.

Will a brute force double loop pass?+

Probably not. The OA has time limits. A double loop is O(n^2), and that fails at n > 1000. Use a hash map to track counts, or sort and use two pointers. Both are O(n log n) or O(n).

What's the most common mistake here?+

Overthinking relationships. Candidates assume they need to store pairs or build connections. You don't. Count valid elements. Use a frequency map and a single pass. Done.

Should I sort the data?+

Not mandatory, but it helps if you use two pointers. Hash table approach is faster if you only count. Try hash table first, it's simpler to code right under time pressure.

Is this still being asked at Trade Desk?+

It was reported in March 2024, so yes, live at that time. The pattern, counting with a hash table, is evergreen. Focus on that, not the specific problem name.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Trade Desk.

OA at Trade Desk?
Invisible during screen share
Get it