Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
Tags
- SW Expert Academy
- 더현대서울 맛집
- 금융문자분석경진대회
- 편스토랑
- Baekjoon
- 프로그래머스 파이썬
- programmers
- Kaggle
- 편스토랑 우승상품
- 캐치카페
- 코로나19
- ChatGPT
- ubuntu
- Git
- 우분투
- github
- 데이콘
- gs25
- hackerrank
- 자연어처리
- 프로그래머스
- Docker
- AI 경진대회
- Real or Not? NLP with Disaster Tweets
- 백준
- dacon
- leetcode
- 파이썬
- 맥북
- PYTHON
Archives
- Today
- Total
솜씨좋은장씨
[leetCode] 448. Find All Numbers Disappeared in an Array (Python) 본문
Programming/코딩 1일 1문제
[leetCode] 448. Find All Numbers Disappeared in an Array (Python)
솜씨좋은장씨 2020. 8. 6. 22:08728x90
반응형
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.
Find all the elements of [1, n] inclusive that do not appear in this array.
Could you do it without extra space and in O(n) runtime? You may assume the returned list does not count as extra space.
Example:
Input:
[4,3,2,7,8,2,3,1]
Output:
[5,6]
Solution
class Solution:
def findDisappearedNumbers(self, nums: List[int]) -> List[int]:
if len(nums) < 0:
answer = []
else:
max_num = len(nums)
answer = list(set(range(1,max_num + 1)) - set(nums))
return answer
SOMJANG/CODINGTEST_PRACTICE
1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.
github.com
'Programming > 코딩 1일 1문제' 카테고리의 다른 글
[leetCode] 551. Student Attendance Record I (Python) (0) | 2020.08.08 |
---|---|
[leetCode] 345. Reverse Vowels of a String (Python) (0) | 2020.08.07 |
[leetCode] 35. Search Insert Position (Python) (0) | 2020.08.05 |
[leetCode] 290. Word Pattern (Python) (0) | 2020.08.04 |
[leetCode] 205. Isomorphic Strings (Python) (0) | 2020.08.03 |
Comments