题解 | #数组中重复的数字#
数组中重复的数字
http://www.nowcoder.com/practice/6fe361ede7e54db1b84adc81d09d8524
使用临时变量存储
class Solution:
def duplicate(self , numbers ):
# write code here
if len(numbers) == 0:
return -1
temp_list = []
duplicate_str = ""
for i in numbers:
if i not in temp_list:
temp_list.append(i)
else:
duplicate_str = i
break
return duplicate_str

查看22道真题和解析