1365. How Many Numbers Are Smaller Than the Current Number

Обновлено: 2024-03-12
1 мин
[]

Содержание

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]