面试题62
Last updated
Last updated
class Solution {
public:
int lastRemaining(int n, int m) {
int index = 0;
// prev round has size 2.
for (int num = 2; num <= n; num++)
index = (index + m) % num;
return index;
}
};