Skip to content

Instantly share code, notes, and snippets.

@mindthink mindthink/
Created Mar 10, 2017

What would you like to do?
leetcode 41:First Missing Positive
class Solution(object):
def firstMissingPositive(self, nums):
:type nums: List[int]
:rtype: int
max_num = len(nums) +1
nums_set = set(nums)
for i in range(1, max_num):
if i not in nums_set:
return i
return max_num
if __name__ == '__main__':
sol = Solution()
x = [10, 11, 12, 0, 0, 0]
y = [1, 2, 0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.