孩子们的游戏 Posted on 2019-08-13 | | reads times 孩子们的游戏题目描述 约瑟夫环问题 12345678910111213141516function LastRemaining_Solution(n, m){ // write code here const circle=[] let del=0; if(n==0||m<=0)return -1; for(var i=0;i<n;i++){ circle[i]=i; } while(circle.length-1){ const k=m-1; del=(del+k)%circle.length; circle.splice(del,1); } return circle[0]} Post author: GoldMiner Xun Post link: https://goldminerxun.github.io/2019/08/13/%E5%89%91%E6%8C%87offer%20JavaScript%E7%89%88%20(46)/ Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 3.0 unless stating additionally.