A python solution

  • 0
    class Solution(object):
        def topKFrequent(self, nums, k):
            d = {}
            for v in nums:
                d[v] = d.get(v, 0) + 1
            l = sorted(d, key=d.get, reverse=True)
            res = []
            for i in range(k):
            return res

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.