Python | Leetcode Python题解之第442题数组中重复的数据
题目:
题解:
class Solution:
def findDuplicates(self, nums: List[int]) -> List[int]:
ans = []
for x in nums:
x = abs(x)
if nums[x - 1] > 0:
nums[x - 1] = -nums[x - 1]
else:
ans.append(x)
return ans