First Missing Positive in Python with O(N) time and O(1) space

  • 0

    It's ...
    kind of Syntactic sugar?hhh ...

    class Solution(object):
        def firstMissingPositive(self, nums):
            :type nums: List[int]
            :rtype: int
            idx = 1
            while True:
                if not idx in nums:
                    return idx
                idx += 1

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.