题解 | #数组中重复的数字#
数组中重复的数字
https://www.nowcoder.com/practice/6fe361ede7e54db1b84adc81d09d8524
class Solution: #注意类的定义 def duplicate(self,nums): new_nums = set() #set()无序且不重复的元素集合 for num in nums: if num in new_nums: return num else: new_nums.add(num) return -1