[parkhojeong] WEEK 11 Solutions - #2851
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🏷️ 알고리즘 패턴 분석
missing-number/parkhojeong.py
class Solution:
def missingNumber(self, nums: List[int]) -> int:
N = max(nums)
num_set = set()
for i in range(N + 1):
num_set.add(i)
for num in nums:
num_set.remove(num)
if len(num_set) == 0:
return N + 1
else:
return num_set.pop()- 패턴: Hash Map / Hash Set, Greedy, Binary Search, Dynamic Programming, Two Pointers, Sliding Window, Backtracking, Divide and Conquer, Union Find, Trie, Bit Manipulation, DFS, BFS, Monotonic Stack, Heap / Priority Queue
- 설명: 집합을 이용해 존재 여부를 체크하는 방식으로 누락된 수를 찾는다. 전체 가능한 숫자 세트를 만든 뒤 주어진 nums에서 제거하는 해시 셋 활용 패턴에 해당한다.
📊 시간/공간 복잡도 분석
| 복잡도 | |
|---|---|
| Time | O(N) |
| Space | O(N) |
피드백: 정수 집합을 만들어 가능한 모든 값을 저장한 뒤 남은 값을 찾는다.
개선 제안: 현재 구현은 최악의 경우 추가적 공간이 필요하므로, 가정된 수의 합이나 비트 연산 등을 이용한 상수 공간 방법을 고려해볼 수 있다.
💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!
Contributor
📊 parkhojeong 님의 학습 현황이번 주 제출 문제
누적 학습 요약
문제 풀이 현황
🤖 이 댓글은 GitHub App을 통해 자동으로 작성되었습니다. 🔢 API 사용량 (gpt-5-nano)
|
Yiseull
reviewed
Sep 5, 2026
Comment on lines
+3
to
+4
| N = max(nums) | ||
| num_set = set() |
Contributor
There was a problem hiding this comment.
정답 범위는 항상 0~n이니까 max 대신 len을 쓰면 더 효율적일 것 같아요!
Yiseull
reviewed
Sep 5, 2026
Comment on lines
+4
to
+7
| num_set = set() | ||
|
|
||
| for i in range(N + 1): | ||
| num_set.add(i) |
Contributor
There was a problem hiding this comment.
num_set = set(range(N + 1)) 로 한 줄에 됩니다! 그리고 크로드한테 물어보니까 저 코드는 파이썬 레벨 루프가 C 레벨로 내려가서 눈에 띄게 빨라진다고 합니다!!👍
Yiseull
approved these changes
Sep 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
답안 제출 문제
작성자 체크 리스트
In Review로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!