Counting Elements 練習題的第一題題目是【MissingInteger】
Find the minimal positive integer not occurring in a given sequence.
方法一:使用 in set 判斷內容值的簡易方式
def solutionByInSet(A):
result = 1
s = set(A)
while result in s:
result += 1
return result
完整練習題 source code 請參閱:github
沒有留言:
張貼留言