Simple Python solution that beats 99.81% submissions

  • 0
    class Solution(object):
        def findDuplicates(self, nums):
            :type nums: List[int]
            :rtype: List[int]
            freq = [0]*(len(nums)+1)
            for i in nums:
                freq[i] += 1
            return [i for i,v in enumerate(freq) if v == 2]

Log in to reply

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