搜狐笔试=。=
当时少想一个slow的指针。。呜呜呜哇的一声哭出来
function kolakoski(token0, token1) { token0 = token0.split(' ') var n = +token0[0], m = +token0[1]; var arr = token1.split(' ').map(function (val) { return +val; }); var num = 0, point = 0, b = [], slow = 0; b[0] = arr[0]; while (num < n) { var cur = b[slow++]; while (cur > 0) { b[num++] = arr[point]; if (num == n) break; cur--; } point = (point + 1) % 4; } b.forEach((val) => { console.log(val); }) }