g0001_0100.s0041_first_missing_positive.Solution.py Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-all Show documentation
Show all versions of leetcode-in-all Show documentation
104 LeetCode algorithm problem solutions
The newest version!
# #Hard #Top_100_Liked_Questions #Top_Interview_Questions #Array #Hash_Table #Udemy_Arrays
# #Big_O_Time_O(n)_Space_O(n) #2024_06_08_Time_334_ms_(98.05%)_Space_34.7_MB_(28.20%)
class Solution:
def firstMissingPositive(self, nums: List[int]) -> int:
counter = 1
nums = set(nums)
while True:
if counter not in nums:
return counter
counter += 1
© 2015 - 2025 Weber Informatics LLC | Privacy Policy