SOURCE

var names = ['a','b','c','d'];
var times = 2;
var chuanhua = function(names,times){
  var queue = new Queue();
  for(var i=0;i<names.length;i++){
    queue.enqueue(names[i])
  }
  var taotai = '';
  while (queue.size() >1 ){
     for(var i=0;i<times;i++){
       queue.enqueue(queue.dequeue())
     }
    taotai = queue.dequeue();
    console.log(taotai+'在击鼓传花中淘汰');
  }
  return queue.dequeue();
}

var winner = chuanhua(names,times);
console.log(winner)
console 命令行工具 X clear

                    
>
console