Simple Counter python


  • 0
    L
    class Solution(object):
        def findErrorNums(self, nums):
            """
            :type nums: List[int]
            :rtype: List[int]
            """
            ret=[]
            ctr=collections.Counter(nums)
            for k,v in ctr.items():
                if v==2:
                    ret.append(k)
                    break
            ret.append(sum(range(1,len(nums)+1))-(sum(nums)-ret[0]))
            return ret

Log in to reply
 

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