We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Hi folks, anyone able to suggest why this wouldn't be working?
It passes all the sample tests, and tests 0, 1, and 11, but not the others.
Have tried taking the test inputs and checking a few parts of them and they seem to work, so I don't know where the issue is.
It's not failing on time
functionminimumBribes(q){// Write your code hereletbribes=0;constreference=[...q];reference.sort((a,b)=>{returna-b})for(leti=0;i<q.length;i++){if(q[i]>reference[i]){letdifference=q[i]-(reference[i])if(difference>2){console.log('Toochaotic')return}else{bribes+=difference}}elseif(q[i]<reference[i]&&q[i+1]<q[i]){bribes++}else{null}}console.log(bribes)}
Cookie support is required to access HackerRank
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 →
Hi folks, anyone able to suggest why this wouldn't be working? It passes all the sample tests, and tests 0, 1, and 11, but not the others. Have tried taking the test inputs and checking a few parts of them and they seem to work, so I don't know where the issue is.
It's not failing on time