As reported: Nutanix SDE-2 (2026), coding round, question 2: LeetCode 1823 — an
O(n·k)queue simulation was coded; time ran out before the optimized approach.
n friends sit in a circle, numbered 1 … n clockwise. Starting at friend 1, count k friends clockwise (including the one you start at); the friend counted last leaves the circle. Continue counting from the next friend. Return the winner — the last friend remaining. This is LeetCode 1823 — Find the Winner of the Circular Game.
Example 1
n = 5, k = 2 -> 3 (2, 4, 1, 5 leave in that order)
Example 2
n = 6, k = 5 -> 1
Constraints: 1 ≤ k ≤ n ≤ 500. Follow-up: linear time and constant space.
Code runner format: one JSON value per line: n, then k (LeetCode's format). Implement findTheWinner(n, k); the harness prints the winner.