1365. How Many Numbers Are Smaller Than the Current Number

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1365

class Solution:
    def smallerNumbersThanCurrent(self, nums: List[int]) -> List[int]:
        cnt = [0] * 102
        for x in nums:
            cnt[x + 1] += 1
        s = list(accumulate(cnt))
        return [s[x] for x in nums]