Python one line with counter


  • -1
    L
    from collections import Counter
    class Solution(object):
        def findDuplicate(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            return [key for key,value in Counter(nums).items() if value>1 ][0]

Log in to reply
 

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