You are viewing a single comment's thread. Return to all comments →
JavaScript:
function minimumBribes(q) { const l = q.length; let chaos = false; let bribes = 0; for(let i = 0; i < l; i++){ let j = i+1; if(q[i] - (i+1) > 2){chaos = true; break;} while(j < q[i]+20){ q[j]<q[i] ? bribes++: 0 j++; } } console.log(chaos ? "Too chaotic" : 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 →
JavaScript: