You are viewing a single comment's thread. Return to all comments →
// Java public static void minimumBribes(List<Integer> q) { int bribes = 0; for (int i = q.size() - 1; i >= 0; i--) { if (q.get(i) - (i + 1) > 2) { System.out.println("Too chaotic"); return; } for (int j = Math.max(0, q.get(i) - 2); j < i; j++) { if (q.get(j) > q.get(i)) { bribes++; } } } System.out.println(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 →