用list模拟的
class Solution { public: list<int> l; int findTheWinner(int n, int k) { for(int i = 1; i <= n; i++) l.push_back(i); int cnt = 0; list<int>::iterator p, r; p = l.begin(); k -= 1; while(l.size() != 1) { for(int i = 0; i < k; i++) { p++; if(p == l.end()) p = l.begin(); } r = p; r++; if(r == l.end()) r = l.begin(); l.erase(p); p = r; } return *(l.begin()); } };