Merged
Conversation
yerim01
reviewed
Mar 7, 2026
| fun containsDuplicate(nums: IntArray): Boolean { | ||
| val set = HashSet<Int>() | ||
| for (num in nums) { | ||
| if (set.contains(num)) { |
Contributor
There was a problem hiding this comment.
코틀린에서도 contains를 쓰는군요 잘 보았습니다!
yerim01
reviewed
Mar 7, 2026
| val complement = target - nums[index] | ||
| val complementIndices = map[complement] | ||
| if (complementIndices != null) { | ||
| for (complementIndex in complementIndices) { |
Contributor
There was a problem hiding this comment.
complementIndices를 순회 하는 부분에서 중첩 for loop 이 생기면서 time complexity가 O(n^2)이 될 수도 있을 것 같은데 제가 이해한게 맞을까요?
Contributor
Author
There was a problem hiding this comment.
이 complementIndices는 최대 사이즈가 2입니다. :)
그래서 n^2와 같은 성능으로 동작하진 않는다고 볼수 있습니다.
acious
commented
Mar 7, 2026
| @@ -0,0 +1,19 @@ | |||
| class Solution { | |||
| // 시간복잡도 : O(n) : map 세팅, O(nlogn) : map value 정렬 = O(nlogn) | |||
| fun topKFrequent(nums: IntArray, k: Int): IntArray { | |||
Contributor
Author
There was a problem hiding this comment.
이건 성능이 꽤 나쁘게 책정되었는데 더 나은 솔루션을 시간이 없어서 적용하지 못했네요.
yerim01
approved these changes
Mar 7, 2026
Contributor
yerim01
left a comment
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 하나 이상을 반드시 검토를 해주셔야 합니다!