Josephus Elimination Until Half Remain
Problem statement
People labeled 1 through n stand clockwise. The current person initially is 1. Advance k positions clockwise, not counting the current person; remove the person landed on. Resume from the next survivor.
Return removals in order, stopping when ceil(n/2) people remain.
Function
eliminateUntilHalf(n: int, k: int) → int[]Examples
Example 1
n = 6k = 4return = [5,4,6]Exclusive counting from 1 lands on 5; continue until three survivors remain.
Constraints
1 <= n <= 10^4.0 <= k <= 10^9.