天天看點

LeetCode 41 First Missing Positive

Given an unsorted integer array nums, find the smallest missing positive integer.

You must implement an algorithm that runs in O(n) time and uses constant extra space.

給你一個未排序的整數數組 nums ,請你找出其中沒有出現的最小的正整數。

請你實作時間複雜度為 O(n) 并且隻使用常數級别額外空間的解決方案。

示例 1:

輸入:nums = [1,2,0]

輸出:3

示例 2:

輸入:nums = [3,4,-1,1]

輸出:2

示例 3:

示例 3:

輸入:nums = [7,8,9,11,12]

輸出:1

待完成