题解 | 切片判断
数组中重复的数字
http://www.nowcoder.com/practice/6fe361ede7e54db1b84adc81d09d8524
for循环,元素i之前的切片判断是否包含元素i,若包含则return结果
class Solution: def duplicate(self , numbers: List[int]) -> int: if len(numbers) != 0: for i in range(len(numbers)): if numbers[i] in numbers[:i]: return numbers[i] else: return -1