Python3 代码
class Solution(object):
def duplicateInArray(self, nums):
"""
:type nums: List[int]
:rtype int
"""
for i in nums:
if i < 0 or i >len(nums)-1:
return -1
temp_set = set()
repeat = -1
for i in range(len(nums)):
temp_set.add(nums[i])
if len(temp_set) < i + 1 :
repeat = nums[i]
break
return repeat