Skip to content

Latest commit

 

History

History

least-number-of-unique-integers-after-k-removals

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Least number of unique integers after k removals

Problem link

Solutions

Solution.py

# https://leetcode.com/problems/least-number-of-unique-integers-after-k-removals/

class Solution:
    def findLeastNumOfUniqueInts(self, arr: List[int], k: int) -> int:
        counts = sorted(Counter(arr).values())
        ret, i = len(counts), 0
        for count in counts:
            if k >= count:
                k -= count
                ret -= 1
            else:
                break
        return ret

Tags