7-line solution in python


  • 0

    hope u like it:P

        def countSmaller(self, nums):
            cnt_array = []
            sorted_array = []
            for i in range(len(nums)-1, -1, -1):
                cnt_array.append(bisect.bisect_left(sorted_array, nums[i]))
                bisect.insort_left(sorted_array, nums[i])
            return cnt_array[::-1]
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.