class Solution:
def findDuplicate(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
for i in range(len(nums)):
index = abs(nums[i])-1
if nums[index] < 0:
return abs(nums[i])
else:
nums[index] = -nums[index]
python leetcode 287. Find the Duplicate Number
猜你喜欢
转载自blog.csdn.net/Neekity/article/details/85135545
今日推荐
周排行