diff --git a/week4/how-many-numbers-are-smaller-than-the-current-number.py b/week4/how-many-numbers-are-smaller-than-the-current-number.py new file mode 100644 index 0000000..e2ed6b0 --- /dev/null +++ b/week4/how-many-numbers-are-smaller-than-the-current-number.py @@ -0,0 +1,12 @@ +class Solution: + def smallerNumbersThanCurrent(self, nums: List[int]) -> List[int]: + sorted_nums=sorted(nums) + dic={} + for i,num in enumerate(sorted_nums): + if not num in dic: + dic[num]=i + ans=[] + for num in nums: + ans.append(dic[num]) + return ans + \ No newline at end of file