def firstMissingPositive(self, A):
least = 1024*1024*1024
# worst case n ops
for i in A:
if i < least and i > 0:
least = i
if least > 1:
return 1
else:
# should be O(n)
A_set = set(A)
# worst case n ops again
while True:
least += 1
if least not in A_set:
return least
I only ask because it seemed too simple for the given problem, which most people here may have seen on Leetcode or someplace similar. Is there something I'm not aware of in Python's implementation of set or dict? Lookup should be O(1) and converting a list to a set should be O(n) from what I understand.