missingintegers
Of course, if you do it normally, it will be returned with N ** 2. So, it seems to be the usual way, but I will make a flag and set it cumulatively. And one lap + the last judgment (live in size (N))
def solution(A):
A = sorted(A)
B = [i for i in A if (0 < i) and (i <= len(A))]
tester = [0] * len(A)
for i in B:
tester[i-1] +=1
try:
return tester.index(0) + 1
except:
return len(B)+1
Recommended Posts