ARTICLE DETAIL

资讯详情

深耕网站视觉设计与运营推广的一线实战洞察。

leetcode 耗时100 1823. Find the Winner of the Circular Game

leetcode 耗时100 1823. Find the Winner of the Circular Game 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]; } };
返回列表