1. 程式人生 > >leetcode python 041首個缺失正數

leetcode python 041首個缺失正數

etc lee 缺失 python code 時間復雜度 leet 正數 for

##限定時間復雜度O(n)
num=[0,5,3,1,2,-2,4,8,5,6]
num=set(num)
d=1
for i in range(1,len(num)+1):
if d in num:
d+=1
else:
break
print(d)

leetcode python 041首個缺失正數