Day30(圆圈中最后剩下的数字–ArrayList)
class Solution {
public int lastRemaining(int n, int m) {
List<Integer> list = new ArrayList<>();
for(int i=0;i<n;i++){
list.add(i);
}
int start = 0;
while(list.size()>1){
int size = list.size();
int delIndex = (start+m-1)%size;
list.remove(delIndex);
start = delIndex;
}
return list.get(0);
}
}