Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 44b37a0

Browse files
Create 1481.py
1 parent a42115f commit 44b37a0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

‎1001-1500/1481.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution:
2+
def findLeastNumOfUniqueInts(self, arr, k):
3+
mp = {}
4+
for x in arr:
5+
mp[x] = mp.get(x, 0) + 1
6+
7+
elements = sorted(mp.items(), key=lambda x: x[1])
8+
9+
for key, value in elements:
10+
if value <= k:
11+
k -= value
12+
del mp[key]
13+
else:
14+
break
15+
return len(mp)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /