New Year Chaos

  • + 0 comments

    My code runs normally in Jupyter but gives different results on this website. Could any please help? Thanks!

    def minimumBribes(q):
        # Write your code here
        n = len(q)
        bribe_count= {j:0 for j in range(n)}
        if n == 1: 
            return 0
        for i in range(1,n):
            for j in range(i):
                if q[j]>q[i]:
                    bribe_count[j]+=1
        sum_count = 0
        for person, count in bribe_count.items():
            if count>2:
                print('Too chaotic')
                return
            sum_count += count
        return sum_count