Reported March 2024
Trade Deskarray

Friend List

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's Friend List problem hit your OA in March 2024, and it's a straightforward array manipulation question that trips candidates who overthink it. You're probably dealing with a list of friend relationships and need to either build, traverse, or count something about the graph they form. The pattern is array-based, but the real trick is recognizing whether you need to track state, deduplicate, or just iterate cleanly. StealthCoder will catch the exact input format and edge cases if you blank on the implementation during the live assessment.

Pattern and pitfall

This problem sits at the intersection of array handling and graph traversal, but most candidates solve it as a pure array problem first. You're likely given a list of pairs or indices representing friendships, and you need to output either a count, a sorted list, or a connectivity check. The common pitfall is assuming the input is sorted or bidirectional when it isn't, or missing that you need to deduplicate pairs (friend A-B is the same as B-A). The actual algorithm is usually two passes through an array or a single pass with a hash set to track seen pairs. If you freeze on the edge case logic mid-OA, StealthCoder runs invisibly and shows you the pattern without the proctor knowing.

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 Friend List 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 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.

Friend List FAQ

Is this a graph problem disguised as an array problem?+

Sort of. You're definitely building or reading a graph, but Trade Desk's version usually keeps you working at the array level. Focus on how pairs are represented (indices, tuples, adjacency list). Once you see the input shape, the algorithm becomes obvious.

Do I need to handle bidirectional friendships?+

Almost certainly. If the input is (A, B), assume B, A is the same relationship. Many candidates miss this and double-count or output duplicates. Check the examples carefully for whether the output should deduplicate or normalize pairs.

What's the time complexity expectation?+

Linear or O(n log n) if sorting is involved. Trade Desk doesn't usually ask for crazy optimizations on this one. A clean pass through the array with a hash set for deduplication will hit the target.

Will this expand into a deeper graph traversal question?+

Unlikely, but possible. If it does, you're looking for connected components or shortest path between two friends. That's when you break out BFS. Read the full problem statement carefully before you code.

How do I prepare in 48 hours if I'm rusty on arrays?+

Know how to iterate, deduplicate with a set, and sort. Practice one LeetCode medium on array deduplication and pair handling. You don't need a deep prep. The assessment tests clarity, not clever tricks.

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