Tournament Rounds by Rank
Reported by candidates from Uber's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The mistake that sinks a first attempt on this Uber OA, reported in May 2026, is sorting the ranks and calling it done. Don't. The problem is a plain bracket simulation. You pair neighbors, keep the smaller number, carry the odd one out forward, and record each round until one player is left. The hintedPattern says sorting, but order is the whole point here. It's easy once you see it, and easy to botch if you panic. If you blank during the live assessment, StealthCoder runs invisibly as a safety net and hands you the loop structure.
The problem
You are given an array ranks representing players in tournament order. A smaller number means a stronger rank. In each round, adjacent players compete: indices 0 and 1, indices 2 and 3, and so on. The player with the smaller rank number advances to the next round. If a round has an odd number of players, the last player advances automatically. Return the list of rounds after each elimination round. Each inner array should contain the ranks that advanced from that round, in order. Continue until one player remains. Function simulateTournamentRounds(ranks: int[]) → int[][] Complete the function simulateTournamentRounds in the editor. simulateTournamentRounds has the following parameter: int ranks[]: player ranks in the initial bracket order Returns int[][]: the advancing ranks after each round Examples Example 1 ranks = [1, 2, 3, 4, 5, 6, 7, 8] return = [[1, 3, 5, 7], [1, 5], [1]] In the first round, the winners are 1, 3, 5, and 7. Then 1 and 5 advance. Finally, 1 wins. Example 2 ranks = [3, 1, 2] return = [[1, 2], [1]] Player 1 beats player 3. Player 2 has no opponent in the first round and advances automatically. Constraints Rank values are distinct. A smaller rank number represents a stronger player. If a round has an odd number of players, the last player advances automatically.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is that there is no trick. Keep a current array. Each round, walk it in steps of two. If index i+1 exists, push min(cur[i], cur[i+1]). Otherwise push cur[i], the bye. Append that new array to your result and repeat until the length is 1. Sorting would destroy the bracket order and give wrong rounds, so leave the input alone. The common pitfalls are mutating the array you're still reading, forgetting the odd-length bye, and looping while length is greater than 0 instead of greater than 1. Also watch the single-player input. With one rank, the loop never runs and you return an empty list. Total work is O(n) since sizes halve each round. StealthCoder is the hedge on the live OA if you freeze on the edge cases.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Tournament Rounds by Rank 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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Uber's OA.
Uber reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Tournament Rounds by Rank FAQ
What's the trick in Tournament Rounds by Rank?+
There isn't a clever one. It's a direct simulation. Pair adjacent elements, keep the smaller rank, let the last element through on odd lengths, store each round, and stop when one player remains. Don't sort the input, because bracket order determines who plays whom.
Should I sort the ranks first?+
No. Sorting changes who faces whom and gives wrong round outputs. Example 2, [3, 1, 2], only works because 3 plays 1 and 2 gets the bye. Process the array in its given order every round.
How do I handle odd-length rounds?+
When you reach the last index with no partner, push that player straight into the next round. Using a step-of-two loop and checking i+1 against the array length covers it cleanly. Test it with [3, 1, 2] before submitting.
What's the time complexity?+
O(n) total. The first round does about n/2 comparisons, the next n/4, and so on, which sums to under n. Space is also O(n) because you store every round's output, which is required by the return type.
How do I prepare for this in 48 hours?+
Write the simulation from scratch twice without looking. Then test the edge cases: one player, two players, odd counts, and a count that stays odd across several rounds. This problem rewards clean loop control more than any algorithm knowledge.