First Missing Positive

Given an unsorted integer array nums. Return the smallest positive integer that is not present in nums. Implement an algorithm that runs in O(n) time and uses O(1) auxiliary space.

Constraints

  • 1 <= nums.length <= 100000
  • -2147483648 <= nums[i] <= 2147483647
Saving… · 2 lines
class Solution:
def firstMissingPositive(self, nums: List[int]) -> int:
Console

Click Run to execute sample tests.