mycode   77.79%

class Solution(object):
    def findDuplicate(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        nums = sorted(nums)
        for i in range(len(nums) - 1):
            if nums[i+1] == nums[i]:
                return nums[i]

参考

class Solution(object):
    def findDuplicate(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        count = [0] * len(nums)
        for n in nums:
            if count[n] == 1:
                return n
            count[n] += 1
        return None