Find the Winner of the Circular Game
Reported by candidates from Bloomberg's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The Bloomberg OA reported in November 2025 dresses up the Josephus problem as a circular game. Players 1 through n stand in a ring, you count k, eliminate, repeat, and return the last one standing. The hinted pattern is simulation, and with n capped at 500 that works fine. But k goes up to 10^9, and that's where people trip. If you blank on the cleanup, StealthCoder is the safety net running invisibly during the live OA. Know the shape of it first and you won't need it.
The problem
Players numbered 1 through n stand in a circle. Starting with player 1, count k remaining players including the current player, eliminate that player, and resume with the next remaining player. Return the final survivor. Function findTheWinner(n: int, k: int) → int Examples Example 1 n = 5 k = 2 return = 3 The elimination order is 2, 4, 1, 5, leaving 3. Constraints 1 <= n <= 500. 1 <= k <= 10^9.
Reported by candidates. Source: FastPrep
Pattern and pitfall
What it really reduces to: Josephus. You have two clean routes. First, simulate with a list and an index. Each step, index = (index + k - 1) % len(list), pop that element, continue until one is left. Always reduce k with the modulo of the current size, never loop k times. That's the pitfall with k up to 10^9. This runs in O(n^2) because of list pops, which is fine for n of 500. Second, the recurrence: f(1) = 0, f(i) = (f(i-1) + k) % i, then return f(n) + 1. That's O(n) time and O(1) space. Off-by-one errors on the 1-indexed answer are the other common miss. If you freeze mid-OA, StealthCoder can read the problem and hand you the recurrence as a hedge. Check it against n = 5, k = 2 giving 3.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Find the Winner of the Circular Game 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
This OA pattern shows up on LeetCode as find the winner of the circular game. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Bloomberg's OA.
Bloomberg 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.
Find the Winner of the Circular Game FAQ
What's the trick in Find the Winner of the Circular Game?+
It's the Josephus problem. Either simulate with a list and a modular index, or use the recurrence f(i) = (f(i-1) + k) % i with f(1) = 0, then add 1 at the end. The recurrence is shorter and avoids list mutation bugs.
Why does k go up to 10^9 if n is only 500?+
It's a trap for naive counting. If you step k times per elimination, you'll time out. Take the modulo against the current number of players, so each elimination is a single index jump instead of a billion steps.
Is plain simulation good enough for the Bloomberg OA?+
Yes, with n at most 500. A list with pops costs O(n^2), which is tiny here. Just make sure you use (index + k - 1) % size for the next removal. The O(n) recurrence is a bonus, not a requirement.
What are the common off-by-one bugs?+
Mixing 0-indexed and 1-indexed positions. The recurrence gives a 0-indexed survivor, so add 1 before returning. In the simulation, the count includes the current player, so you jump k - 1 positions ahead, not k. Test with n = 5, k = 2 expecting 3.
How do I prepare for this in 48 hours?+
Code both versions once from scratch. Write the list simulation, then derive the recurrence and confirm both return 3 on the sample. Then test edge cases: n = 1, k = 1, and a huge k. That covers nearly everything this problem can throw at you.