You are viewing a single comment's thread. Return to all comments →
C#
public static void minimumBribes(List<int> q) { int b = 0; for (int i = q.Count - 1; i > 0; i--) { for (int j = i; j > i - 2 && j > 0; j--) { if (q[i] < q[j - 1]) { (q[i], q[j - 1]) = (q[j - 1], q[i]); b++; } } if (q[i] != i+1) { Console.WriteLine("Too chaotic"); return; } } Console.WriteLine(b); ``}
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 →
C#