1481. 不同整数的最少数目

Medium

思路

周赛这道题没有花多久

以上,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