队列的应用
import java.util.LinkedList;
import java.util.Queue;
public class Solution {
public int LastRemaining_Solution(int n, int m) {
if(n<1) return -1;
Queue<Integer>queue=new LinkedList<Integer>();
for(int i=0;i<n;i++){
queue.offer(i);
}
while(queue.size()!=1){
for(int i=0;i<m-1;i++){
int x=queue.poll();
queue.offer(x);
}
int x=queue.poll();
}
return queue.peek();
}
}