Skip to content

[sukyoungshin] WEEK 01 #1178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 5, 2025
Merged

[sukyoungshin] WEEK 01 #1178

merged 10 commits into from
Apr 5, 2025

Conversation

sukyoungshin
Copy link
Contributor

@sukyoungshin sukyoungshin commented Apr 3, 2025

답안 제출 문제

작성자 체크 리스트

  • 우측 메뉴에서 PR을 Projects에 추가해주세요.
  • Projects의 오른쪽 버튼(▼)을 눌러 확장한 뒤, Week를 현재 주차로 설정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 StatusIn Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

검토자 체크 리스트

Important

본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!

  • 바로 이전에 올라온 PR에 본인을 코드 리뷰어로 추가해주세요.
  • 본인이 검토해야하는 PR의 답안 코드에 피드백을 주세요.
  • 토요일 전까지 PR을 병합할 수 있도록 승인해주세요.

Copy link
Contributor

@yoouyeon yoouyeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4문제 푸시느라 고생 많으셨습니다 👏👏👏👏 남은 한문제도 화이팅입니다!! 🍀

Comment on lines 98 to 100
if (heap.length > k) {
heap.shift();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기서는 heap의 크기가 그렇게 크지 않아서 큰 영향은 없을 것 같지만,,,
shift 메서드는 제거한 뒤에 남은 원소들을 앞쪽으로 당기기 때문에 시간복잡도가 O(n)으로 크기가 큰 배열에서는 성능이 좋지 않은 메서드라고 알고 있어요! (참고 블로그)
오름차순이 아닌 내림차순으로 정렬한 뒤에 heap.pop()으로 뒤쪽 원소를 제거한다면 좀 더 빠르게 적게 등장한 원소를 제거할 수 있을 것 같아서 코멘트 남겨봅니당 ㅎㅎ

Comment on lines 20 to 24
const index = nums.indexOf(j);

if (nums.includes(j) && i !== index) {
return [i, index];
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indexOf 메서드는 만약에 jnums에서 찾지 못하면 -1을 반환하는 것으로 알고 있어요! (mdn 참고)
nums.includes(j)를 조건문에서 한번 더 쓰게 되면 nums에서 원소를 찾는 연산이 중복이 되는 것 같아서...
indexOf 의 결과가 -1인지 확인해주는 방법을 써도 좋을 것 같아요!!

Comment on lines 40 to 45
function topKFrequent(nums: number[], k: number): number[] {
const frequencyMap = buildFrequencyMap2(nums);
const frequencyBuckets = buildFrequencyBuckets(nums.length, frequencyMap);

return collectTopKFrequent(frequencyBuckets, k);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

알고리즘 풀이를 할 때에는 함수를 잘 분리하지 않게 되던데... 함수를 잘 분리해 주셔서 덕분에 긴 흐름을 잘 이해할 수 있었습니다 👍👍

}

return [];
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

지금 linelint에서 에러가 나고 있는데 답안 제출 가이드를 보니 파일 끝에 개행문자를 추가해야 한다고 해요!
two-sum이랑 top-k-frequent-elements 쪽 파일 끝 개행문자 추가해주시면 에러도 해결될 듯 합니다 ㅎㅎ

@sukyoungshin sukyoungshin moved this from Solving to In Review in 리트코드 스터디 4기 Apr 5, 2025
@sukyoungshin
Copy link
Contributor Author

sukyoungshin commented Apr 5, 2025

꼼꼼하게 코드리뷰 해주셔서 감사합니다, @yoouyeon 님!
코드리뷰 적용 확인 및 Approve 부탁드립니다~

Copy link
Contributor

@yoouyeon yoouyeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 반영까지...!! 감사합니다 😊 마지막 문제까지 정말 수고 많으셨어요!!! 👏👏

@sukyoungshin sukyoungshin merged commit 5c9fdf6 into DaleStudy:main Apr 5, 2025
1 check passed
@github-project-automation github-project-automation bot moved this from In Review to Completed in 리트코드 스터디 4기 Apr 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

2 participants