java解法
import java.util.LinkedList; public class Solution { public int LastRemaining_Solution(int n, int m) { if(n<=0) return -1; if(n==1) return 1; LinkedList<Integer> arr = new LinkedList(); for(int i=0;i<n;++i) arr.add(i); int index = -1; int size = arr.size(); while(size>1) { int t = m+index; while(t>=size) t-=size; index = t; arr.remove(index--); size--; } return arr.get(0); }}