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.
publicstaticvoidminimumBribes(List<int>q){inttotalBribes=0;for(inti=q.Count-1;i>=0;i--){// if the current person moves than 2 spotsif(q[i]-(i+1)>2){Console.WriteLine("Too chaotic");return;}// Sum up the bribesfor(intj=Math.Max(0,q[i]-2);j<i;j++){if(q[j]>q[i]){totalBribes++;}}}Console.WriteLine(totalBribes);}
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 →
Solution for c#