본문 바로가기

IT/코딩테스트

[Leetcode] 41. First Missing Positive

728x90

https://leetcode.com/problems/first-missing-positive

class Solution:
    def firstMissingPositive(self, nums: List[int]) -> int:
        nums.sort()

        result = 1

        for n in nums:
            if n <= 0:
                continue
            if n == result:
                result += 1

        return result
728x90