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
'IT > 코딩테스트' 카테고리의 다른 글
[Leetcode] 3099. Harshad Number (0) | 2024.03.31 |
---|---|
[Leetcode] 2962. Count Subarrays Where Max Element Appears at Least K Times (0) | 2024.03.29 |
[Leetcode] 442. Find All Duplicates in an Array (0) | 2024.03.25 |
[Leetcode] 287. Find the Duplicate Number (0) | 2024.03.24 |
[Leetcode] 143. Reorder List (0) | 2024.03.23 |