Merged
Conversation
contains-duplicate/hj4645.py
Outdated
| # Time Complexity | ||
| # - set(nums) → O(n) | ||
| # - len(nums), len(set(nums)) → O(1) | ||
| # - Total: O(n) (n = number of list elements) No newline at end of file |
Contributor
There was a problem hiding this comment.
lint error 로 줄바꿈 검사 오류입니다. 마지막 줄 한 줄 추가해주세요.
Contributor
Author
There was a problem hiding this comment.
@printjin-gmailcom 안녕하세요
커밋 #f310a52로 개행문자 추가되어 있습니다
감사합니다!
printjin-gmailcom
approved these changes
Jul 26, 2025
Contributor
printjin-gmailcom
left a comment
There was a problem hiding this comment.
첫 주 수고하셨습니다. 2주차도 화이팅입니다 :)
| # 순서가 보장되는 python dictionary를 사용해서, | ||
| # 요소 x에 대해서 target-x 가 딕셔너리 내에 있는지를 찾는다. | ||
| def twoSum(self, nums: List[int], target: int) -> List[int]: | ||
| dict = {} |
Contributor
There was a problem hiding this comment.
dict는 파이썬 내장 타입이라 변수명으로 사용하면 좋지 않습니다. 참고 부탁드립니다
| class Solution: | ||
| # nums 에서 가장 빈도가 높은 k개의 요소를 찾는 문제 | ||
| # 딕셔너리와 정렬을 사용해 해결 | ||
| # 시간복잡도: O(n log n), 공간복잡도: O(n) |
Contributor
There was a problem hiding this comment.
heapq나 bucket sort를 쓰면 O(n) 또는 O(n log k)로 더 빠르게 가능합니다. 물론 가독성과 정확성으로는 이 방법이 가장 좋아보이긴 합니다.
hyer0705
reviewed
Jul 27, 2025
| # 리스트 안에 동일한 숫자가 2개 이상 존재하면 true를 반환해야 하는 문제 | ||
| # Set으로 변환 시 중복이 제거되므로 List와 Set의 크기를 비교해 답을 구할 수 있음 | ||
| def containsDuplicate(self, nums: List[int]) -> bool: | ||
| return len(nums) != len(set(nums)) |
Contributor
There was a problem hiding this comment.
저도 이런 로직으로 풀이해서 바로 이해가 되었습니다.
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 하나 이상을 반드시 검토를 해주셔야 합니다!