New Year Chaos

  • + 0 comments

    This approach is mostly about the fact that we only need to count all people in front of us (who could bribe the current person and not more than two bigger than us) def minimumBribes(q): bribes = 0

    for i in range(len(q)):
        if q[i] - (i + 1) > 2:  
            print("Too chaotic")
            return
    
        for j in range(max(0, q[i] - 2), i):
            if q[j] > q[i]:  
                bribes += 1
    
    print(bribes)