You are viewing a single comment's thread. Return to all comments →
JS
function minimumBribes(queue) { let bribes = "Too chaotic"; if (! queue.some((value, index) => value - index > 3)) { bribes = 0; for (let _ in [undefined, undefined]) { for (let index = queue.length - 1; index > 0; index--) { if (queue[index] < queue[index - 1]) { [queue[index], queue[index - 1]] = [queue[index - 1], queue[index]]; bribes++; } } } } console.log(bribes); }
Seems like cookies are disabled on this browser, please enable them to open this website
New Year Chaos
You are viewing a single comment's thread. Return to all comments →
JS