题目链接:1823. 找出游戏的获胜者
使用队列模拟。
class Solution:
def findTheWinner(self, n: int, k: int) -> int:
players = list(range(n))
cur = 0
while len(players) > 1:
idx = (cur + k - 1) % len(players)
players.pop(idx)
cur = idx
return players.pop() + 1