Skip to content

Commit

Permalink
Create smallest-missing-positive.py
Browse files Browse the repository at this point in the history
finds the smallest missing positive integer in a sequence
  • Loading branch information
gabedonnan authored Jan 12, 2023
1 parent ec384b6 commit 8987ced
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions smallest-missing-positive.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Solution(object):
def firstMissingPositive(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
smallest = 1
num_dict = {}
for num in nums:
num_dict[num] = 1
while smallest < 2147483648:
if smallest not in num_dict:
return smallest
smallest += 1
#return

0 comments on commit 8987ced

Please sign in to comment.