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