Reported September 2026
Pinterestdesign

Escape Room Leaderboard

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

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

Pinterest reported this one in September 2026, and it looks like a leaderboard problem until you read the complexity line. It really reduces to one doubly linked list per room, with a map from player to node. ADVANCE and GET are constant time, and LEADERBOARD walks rooms from roomCount down to 0. If you have the OA in a day or two, this is the shape to memorize. StealthCoder sits as a safety net on the live OA if you blank on the linked list bookkeeping, but the idea is small enough to hold in your head.

The problem

Players progress through escape rooms numbered from 0 through roomCount. Every player in players begins in room 0. Their initial entry order into room 0 is their order in players.
Process operations in order:
ADVANCE playerId: move the player from room r to room r + 1 and return the new room as a decimal string. The operation is valid only when r < roomCount.
GET playerId: return the player's current room as a decimal string.
LEADERBOARD k: return up to k player identifiers, ordered by decreasing room number. Players in the same room are ordered by when they entered that room; earlier entry comes first. Encode the identifiers as one comma-separated string, or an empty string when k == 0.
Return one result string for every operation. The intended data structure supports ADVANCE and GET in constant time and LEADERBOARD in O(roomCount + k) time.

Function
runEscapeRoomLeaderboard(players: String[], roomCount: int, operations: String[]) → String[]

Examples
Example 1
players = ["A","B"]
roomCount = 3
operations = ["ADVANCE A","ADVANCE B","ADVANCE A","LEADERBOARD 2","GET B"]
return = ["1","1","2","A,B","1"]
A reaches room 2 while B remains in room 1, so the leaderboard is A,B.
Example 2
players = ["A","B","C"]
roomCount = 2
operations = ["ADVANCE A","ADVANCE B","LEADERBOARD 3"]
return = ["1","1","A,B,C"]
A entered room 1 before B, so that tie keeps A first. C follows from room 0.
Example 3
players = ["x","y"]
roomCount = 1
operations = ["GET y","LEADERBOARD 1","LEADERBOARD 0"]
return = ["0","x",""]
Both players remain in room 0, where the original player order breaks the tie. A request for zero players returns an empty string.

Constraints
1 <= players.length <= 100000
1 <= roomCount <= 100000
0 <= operations.length <= 200000
Player identifiers are unique nonempty ASCII strings without spaces or commas.
Every player referenced by an operation exists.
Every ADVANCE operation is valid.
0 <= k <= players.length for every LEADERBOARD operation.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Keep an array of roomCount+1 buckets. Each bucket is a doubly linked list ordered by entry time into that room. Initially room 0 holds all players in input order. ADVANCE removes the player's node from room r in O(1) and appends it to the tail of room r+1, so earlier entrants stay ahead. That tail append is what encodes the tie-break rule. GET just reads the player's room from a map. LEADERBOARD loops rooms from high to low, walks each list, and stops once k ids are collected. That's O(roomCount + k). The common pitfall is sorting on every query, which blows the budget with 200000 operations. Another is forgetting to unlink the node before reinserting, which corrupts the list. Return k = 0 as an empty string. StealthCoder is your hedge in the live OA if the pointer handling slips under pressure.

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 Escape Room Leaderboard 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

⏵ The honest play

You've seen the question. Make sure you actually pass Pinterest's OA.

Pinterest 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.

Escape Room Leaderboard FAQ

What's the trick in Escape Room Leaderboard?+

Use one linked list per room, appended at the tail on ADVANCE. Tail insertion preserves entry order inside a room, which is the tie-break. A hash map from player id to node and room gives constant time moves and lookups. Leaderboard just scans rooms top down.

Why not sort players for each LEADERBOARD call?+

Sorting costs O(n log n) per query, and with up to 200000 operations and 100000 players that's far too slow. The statement even states the target: O(roomCount + k). Bucketing by room makes the order implicit, so you only read, never sort.

How do I handle ties in the same room?+

Ties break by when the player entered that room, earlier first. Players start in room 0 in input order. Each time someone advances, append them to the end of the next room's list. Never reorder a list afterward, and the tie rule holds automatically.

Can I use arrays or deques instead of linked lists?+

Deletion from the middle of an array is O(n), so ADVANCE would break the constant time requirement. You need O(1) removal of an arbitrary player, which means doubly linked nodes. Some people use ordered sets with entry counters, but that adds a log factor you don't need.

How do I prep for this in 48 hours?+

Code it once from scratch with a node class, prev and next pointers, and head and tail per room. Test the three examples, especially k = 0 and the all-in-room-0 case. Practice joining ids into a comma string efficiently. Then do one similar design problem, like an LRU cache, for pointer practice.

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

OA at Pinterest?
Invisible during screen share
Get it