728x90
1부터 n까지 있는 리스트 nums에 빠진 리스트를 return하는 문제
class Solution:
def findDisappearedNumbers(self, nums: List[int]) -> List[int]:
s = set(nums)
return [i for i in range(1, len(nums)+1) if i not in s]
Runtime : 19ms (92.77%)
Memory : 31.50MB (41.04%)
728x90
'코딩 공부 > Leetcode' 카테고리의 다른 글
[Python] 3105. Longest Strictly Increasing or Strictly Decreasing Subarray (0) | 2025.02.03 |
---|---|
[Python] 1752. Check if Array Is Sorted and Rotated (0) | 2025.02.03 |
[Python] 414. Third Maximum Number (0) | 2025.02.01 |
[Python] 1051. Height Checker (0) | 2025.01.31 |
[Python] 905. Sort Array By Parity (0) | 2025.01.30 |