leetcode 耗时100 1823. Find the Winner of the Circular Game
发布时间:2026/9/26 18:34:59 作者:尧图编辑部 阅读量:1,286

Problem: 1823. 找出游戏的获胜者每当前进一次就删除这个数字直到剩下一个数字耗时100Codeclass Solution { public: int findTheWinner(int n, int k) { int ind -1; vectorint status; for(int i 1; i n; i) status.push_back(i); while((int)status.size() 1) { ind (ind k) % n; status.erase(status.begin() ind); n--; ind--; } return status[0]; } };