def minpositive(a): A = set(a) ans = 1 while ans in A: ans += 1 return ans
Here is what the above code is Doing:
1. It’s creating a set of all the elements in the list.
2. It’s initializing the answer to 1.
3. It’s checking if 1 is in the set. If it is, it increments the answer by 1 and checks again.
4. If 1 is not in the set, it returns the answer.
The time complexity of this code is O(N) because we’re iterating through the entire list.