[Kyojin-Hwang] WEEK 01 solutions #1682
Merged
KyoJin-Hwang merged 5 commits intoDaleStudy:mainfrom Jul 26, 2025
KyoJin-Hwang:main
Merged
[Kyojin-Hwang] WEEK 01 solutions #1682KyoJin-Hwang merged 5 commits intoDaleStudy:mainfrom KyoJin-Hwang:main
KyoJin-Hwang merged 5 commits intoDaleStudy:mainfrom
KyoJin-Hwang:main
Conversation
hi-rachel
approved these changes
Jul 26, 2025
| .sort((a, b) => b[1] - a[1]) // 빈도 기준으로 정렬 | ||
| .map((entry) => entry[0]); // 숫자만 추출 | ||
|
|
||
| for (let i = 0; i < k; i++) { |
Contributor
There was a problem hiding this comment.
return sorted.slice(0, k);
slice를 활용하면 바로 반환도 가능합니다.
Contributor
Author
There was a problem hiding this comment.
오 그런 방법이 있었네용!!
|
|
||
| return false; | ||
| }; | ||
|
|
Contributor
There was a problem hiding this comment.
var containsDuplicate = function (nums) {
const seen = new Set();
for (let num of nums) {
if (seen.has(num)) return true;
seen.add(num);
}
return false;
};
Set 자료구조를 사용한다면 중복을 제거하고 메모리, 속도 측면에서 좋다고 생각합니다.
| const map = new Map(); | ||
|
|
||
| for (let num of nums) { | ||
| map.set(num, (map.get(num) || 0) + 1); |
Contributor
There was a problem hiding this comment.
js에서 Map 활용을 잘하시고 계시네요 👍🏻
Contributor
Author
|
@hi-rachel 레이첼님 검토자 체크리스트 체크 한번만 부탁드리겠습니당 ㅎㅎ! |
Contributor
검토자 체크 리스트 본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다! 바로 이전에 올라온 PR에 본인을 코드 리뷰어로 추가해주세요. 어떤걸 확인하라는걸까요? |
Contributor
Author
|
그 체크가 안되어 있어서 체크 해주시는게 아닐까요? |
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 하나 이상을 반드시 검토를 해주셔야 합니다!