Last Round for Each Player
Reported by candidates from DRW's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The whole problem hinges on one thing: a list you shrink round by round, where each entry remembers which player it came from. DRW reported this OA in July 2026, and it's a clean simulation. You've got N players in a bracket, the higher skill wins, and you need the last round each player appears in. If your invite says DRW and you're 48 hours out, this is a good one to see coming. It's not tricky, but it punishes sloppy indexing. StealthCoder sits invisibly on your screen as a safety net if you blank mid-assessment, but the logic below is short enough to carry in your head.
The problem
There are N players, numbered from 0 to N - 1, participating in a tournament. Player k has skill level skills[k]. No two players have the same skill level. The tournament is played in rounds for as long as there are at least two players remaining. In the first round, player 0 faces player 1, player 2 faces player 3, and so on. In the second round, the winner of the match between players 0 and 1 faces the winner of the match between players 2 and 3, and so on. The player with the higher skill level wins the match. For example, for skills = [4, 2, 7, 3, 1, 8, 6, 5], the tournament is as follows (numbers in circles are skill levels): round 3: ⑦───final───⑧ ╱ ╲ ╱ ╲ round 2: ④ ⑦ ⑧ ⑥ ╱ ╲ ╱ ╲ ╱ ╲ ╱ ╲ round 1: ④ ② ⑦ ③ ① ⑧ ⑥ ⑤ ────────────────────── player: 0 1 2 3 4 5 6 7 For each player, find the last round in the tournament in which they participate. Function solution(skills: int[]) → int[] Examples Example 1 skills = [4, 2, 7, 3, 1, 8, 6, 5] return = [2, 1, 3, 1, 1, 3, 2, 1] Players 1, 3, 4, and 7 lose in round 1. Players 0 and 6 lose in round 2. Players 2 and 5 reach the final, so their last participation round is 3. Example 2 skills = [9, 1] return = [1, 1] The only match is the final. Both players participate in round 1, even though player 0 wins the tournament. Example 3 skills = [1, 4, 3, 2] return = [1, 2, 2, 1] Player 0 loses to player 1, and player 3 loses to player 2 in round 1. Players 1 and 2 meet in round 2, so both have last participation round 2. Constraints skills.length >= 2. For this exercise, skills.length is a power of two. Every value in skills is an integer. All values in skills are distinct.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Simulate the bracket directly. Keep a list of surviving player indices. Start with round = 1 and every player alive. Each round, pair up neighbors in the list (positions 0 and 1, 2 and 3, and so on). Every player in the current list participates, so set result[player] = round for all of them. Then keep the one with the higher skills[] value from each pair and move on with round + 1. Stop when one player is left, because that player's last round was already recorded in the final. The common pitfall is forgetting to record the winner of the final, or tracking skill values instead of original indices so you can't write back to the right slot. Total work is O(N), since the list halves each round. The power-of-two guarantee means no byes. If you blank on the live OA, StealthCoder is the hedge, but this pattern is simple enough to rebuild from the examples.
If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.
You can drill Last Round for Each Player 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 StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass DRW's OA.
DRW 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.
Last Round for Each Player FAQ
How hard is the DRW Last Round for Each Player problem really?+
Easy to medium. There's no clever algorithm, just careful simulation. The risk is off-by-one on the round number or losing track of original player indices. If you can write a loop that halves a list, you can solve it.
What's the trick to this problem?+
Store indices, not skill values, in your surviving list. Each round, mark every current player's last round as the current round number, then keep the higher-skilled one of each adjacent pair. Repeat until one player remains.
Do I need a fancy data structure?+
No. A plain array or list of surviving indices is enough. You rebuild it each round with half as many entries. A queue works too, but it isn't required for correctness or speed.
What's the time complexity?+
O(N). Round one touches N players, round two touches N/2, and so on, which sums to under 2N. Space is O(N) for the result array and the surviving list. Nothing here needs to be faster.
How do I prepare for this in 48 hours?+
Hand-trace Example 1 and Example 3 on paper until the round numbers match. Then code the loop once from scratch. Test the two-player case, since the winner still gets round 1. That covers the edge cases this problem has.