Medium
周赛这道题没有花多久
k
个数量中,能删除的数字的种类是最多的以上,AC!
python3
class Solution:
def findLeastNumOfUniqueInts(self, arr: List[int], k: int) -> int:
c = collections.Counter(arr)
temp = 0
remove = 0
sc = sorted(c.values())
for v in sc:
if v <= k:
k = k - v
remove += 1
return len(c) - remove