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.
running my code in local IDE for
List.of(1, 2, 5, 3, 7, 8, 6, 4)
prints "Too chaotic".
even using "Test agains custom input", I have same outcome.
but when using [Run Code] button, it fails.
any suggestions?
publicstaticvoidminimumBribes(List<Integer>q){// Write your code hereList<Integer>sorted=q.stream().sorted().collect(Collectors.toList());inttotalBribes=0;for(inti=0;i<sorted.size();i++){intinitialIndex=q.indexOf(sorted.get(i));intdistance=Math.abs(initialIndex-i);if(distance>2){System.out.println("Too chaotic");return;}totalBribes+=distance;}System.out.println(totalBribes/2);// bribes are counted both dire
}
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 →
running my code in local IDE for List.of(1, 2, 5, 3, 7, 8, 6, 4) prints "Too chaotic". even using "Test agains custom input", I have same outcome. but when using [Run Code] button, it fails.
any suggestions?