You are viewing a single comment's thread. Return to all comments →
Python 3
def minimumBribes(q): bribe = 0 for i in range(len(q)-1, 0, -1): if q[i] != i+1: if q[i-1] == i+1: q[i], q[i-1] = q[i-1], q[i] bribe += 1 elif q[i-2] == i+1: q[i-2], q[i-1], q[i] = q[i-1], q[i], q[i-2] bribe += 2 else: print("Too chaotic") return print(bribe)
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 →
Python 3