# Time Complexity - O(n log(n))
class Solution:
    def topKFrequent(self, nums: List[int], k: int) -> List[int]:
        dairy = {}
        # O(n)
        for num in nums:
            dairy[num] = dairy.get(num,0) + 1 
        # O(n log(n))
        unique = dairy.keys()
        unique.sort(key = lambda x:dairy[x])
        
        return unique[-k:]
        
# Time Complexity - O(n log(k))

class Solution:
    def topKFrequent(self, nums: List[int], k: int) -> List[int]:
        dairy = {}
        # O(n)
        for num in nums:
            dairy[num] = dairy.get(num,0) + 1 
        # O(n log(k))
        return heapq.nlargest(k,dairy.keys(),key = dairy.get)
 
67cd7d33e4ebaced6485450e912945526199f43f
<mask token>


class Solution:
    <mask token>

<mask token>


class Solution:

    def topKFrequent(self, nums: List[int], k: int) ->List[int]:
        dairy = {}
        for num in nums:
            dairy[num] = dairy.get(num, 0) + 1
        return heapq.nlargest(k, dairy.keys(), key=dairy.get)

class Solution:
    <mask token>


class Solution:

    def topKFrequent(self, nums: List[int], k: int) ->List[int]:
        dairy = {}
        for num in nums:
            dairy[num] = dairy.get(num, 0) + 1
        return heapq.nlargest(k, dairy.keys(), key=dairy.get)

class Solution:

    def topKFrequent(self, nums: List[int], k: int) ->List[int]:
        dairy = {}
        for num in nums:
            dairy[num] = dairy.get(num, 0) + 1
        unique = dairy.keys()
        unique.sort(key=lambda x: dairy[x])
        return unique[-k:]


class Solution:

    def topKFrequent(self, nums: List[int], k: int) ->List[int]:
        dairy = {}
        for num in nums:
            dairy[num] = dairy.get(num, 0) + 1
        return heapq.nlargest(k, dairy.keys(), key=dairy.get)

# Time Complexity - O(n log(n))
class Solution:
    def topKFrequent(self, nums: List[int], k: int) -> List[int]:
        dairy = {}
        # O(n)
        for num in nums:
            dairy[num] = dairy.get(num,0) + 1 
        # O(n log(n))
        unique = dairy.keys()
        unique.sort(key = lambda x:dairy[x])
        
        return unique[-k:]
        
# Time Complexity - O(n log(k))

class Solution:
    def topKFrequent(self, nums: List[int], k: int) -> List[int]:
        dairy = {}
        # O(n)
        for num in nums:
            dairy[num] = dairy.get(num,0) + 1 
        # O(n log(k))
        return heapq.nlargest(k,dairy.keys(),key = dairy.get)
 