import bisect

def countSmaller(nums):
    counts = []
    done = []
    for num in nums[::-1]:
        counts.insert(0, bisect.bisect_left(done, num))
        bisect.insort(done, num)
    return counts
    
count = countSmaller([5,2,6,1])


print(count)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: