Skip to content

Commit

Permalink
Added solution for How Many Numbers Are Smaller Than the Current Number
Browse files Browse the repository at this point in the history
  • Loading branch information
Blacknahil committed Dec 29, 2023
1 parent 567516b commit f91b944
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions week4/how-many-numbers-are-smaller-than-the-current-number.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f91b944

Please sign in to comment.