First Missing Positive

Advanced

Welcome to this magical coding challenge, young coder! ๐Ÿง™โ€โ™‚๏ธ Today, we're diving into the mystical world of numbers to find the "first missing positive" number from a list.

The first missing positive number is the smallest positive integer that doesn't appear in the list. For example, if you have a list [3, 4, -1, 1], the number 2 is missing, and that's our answer!

Task

You are given a list of integers, which can contain both positive and negative numbers, and even duplicates. Your task is to write a function first_missing_positive that returns the smallest positive integer that is missing from the list.

Examples

first_missing_positive([3, 4, -1, 1]) # Returns: 2, because 1 is in the list, but 2 is the smallest positive missing. first_missing_positive([1, 2, 0]) # Returns: 3, because 1 and 2 are in the list, but 3 is missing. first_missing_positive([7, 8, 9, 11, 12]) # Returns: 1, because all positive numbers less than 7 are missing! first_missing_positive([1, 1, 3, 3, 2, 2]) # Returns: 4, because 1, 2, and 3 are there, but 4 is not.

Adventure Awaits

Find the first missing positive integer! Start solving this puzzle and unleash the coder within you! ๐Ÿš€

Geek
Inputs

Arg 1:

[3,4,-1,1]
Expected Output
2
Actual Output