Find the Smallest Missing Positive Integer

Advanced

Welcome, young coder! 🚀

In this challenge, we're going to embark on a magical journey to find a lost number! But not just any number... We're looking for the smallest missing positive integer from a given list of numbers. Let's help this number find its way back!

Here's what you need to do:

Write a function find_smallest_missing_positive_integer that takes a list of integers and returns the smallest positive integer that is not present in the list. Positive integers are numbers like 1, 2, 3, and so on.

Examples:

Imagine the list is [1, 2, 0, 4, 5]:

find_smallest_missing_positive_integer([1, 2, 0, 4, 5])

The function should return 3 because 3 is the smallest positive number not in the list.

For the list [3, 4, -1, 1]:

find_smallest_missing_positive_integer([3, 4, -1, 1])

The result should be 2 since 2 is the smallest positive number not present.

One last example, with a full continuous list [1, 2, 3, 4, 5]:

find_smallest_missing_positive_integer([1, 2, 3, 4, 5])

It should return 6 because all other positive numbers before 6 are present.

Let's save that missing number! 🧙‍♂️ Remember, the list can contain negative numbers and zeros, but we're only interested in finding the smallest missing positive integer.

Geek
Inputs

Arg 1:

[1,2,0,4,5]
Expected Output
3
Actual Output
Find the Smallest Missing Positive Integer [advanced] | Coding for Kids