Skip to content

[mmyeon] Week 1 #1144

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 6 commits into from
Apr 4, 2025
Merged

[mmyeon] Week 1 #1144

merged 6 commits into from
Apr 4, 2025

Conversation

mmyeon
Copy link
Contributor

@mmyeon mmyeon commented Mar 31, 2025

답안 제출 문제

작성자 체크 리스트

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

검토자 체크 리스트

Important

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

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

* - 최악의 경우, nums 배열 크기만큼 map에 저장하니까 O(n)
*/
function twoSum(nums: number[], target: number): number[] {
const seenNumbers = new Map<number, number>();
Copy link
Contributor

Choose a reason for hiding this comment

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

new 이후에 free가 없어서 검색해 봤는데 javascript는 new 이후에 free 가 필요 없군요
새로운 사실을 알았습니다. 감사합니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@PDKhan
안녕하세요 반갑습니다!
리뷰 남겨주셔서 감사해요.

어떤 언어 사용하시는지 궁금해서 PR 체크해봤는데, 제 다음 PR 작성자가 아니시더라구요.
아마 리뷰어 할당에 착오가 있으셨던 것 같아요.

PDKhan님 PR 이전 PR에 다시 한 번 할당 부탁드립니다~
제 PR 리뷰어는 제가 수정하겠습니다!

Copy link
Contributor

Choose a reason for hiding this comment

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

@mmyeon 제가 PR을 작성했다가 삭제해서 그렇게 되었습니다.
혼동을 드려 죄송합니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@PDKhan
아하 그러셨군요!
리뷰 다시 한번 감사드려요 :)
1주차 문제 풀이 파이팅입니다!!

@PDKhan PDKhan self-requested a review March 31, 2025 06:10
@mmyeon mmyeon requested review from Moonjonghoo and removed request for PDKhan April 2, 2025 04:35
@mmyeon mmyeon moved this from Solving to In Review in 리트코드 스터디 4기 Apr 4, 2025
Copy link
Contributor

@Moonjonghoo Moonjonghoo left a comment

Choose a reason for hiding this comment

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

전반적으로 풀이하신 코드들이 가독성이 좋았고, 리뷰어이자 참여자였던 제 풀이보다 시간복잡도와 공간복도 측면에서 훨씬 더 깊이 고민하신 게 느껴졌습니다.

덕분에 저도 앞으로는 코드 작성 시 주석을 활용하고, 복잡도도 더 신경 써야겠다는 생각을 하게 되었어요.

이번 리뷰는 오히려 학습의 기회가 된 느낌이라 조금 죄송한 마음이 들지만..ㅎㅎ
한 주 동안 정말 고생 많으셨습니다! 🙏

*/
function containsDuplicate(nums: number[]): boolean {
return nums.length !== new Set([...nums]).size;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

한줄로 깔끔하게 구현해주시고, 복잡도를 다 작성해주셔서 확인하기 편했습니다!
궁금한점은 nums를 Set로 변환할떄, 스프레드 연산자를 사용해서 작성하신 이유가 따로 있을까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

앗 이 부분은 불필요하게 스프레드 연산자가 사용되었네요!
수정하곘습니다. 꼼꼼하게 리뷰해주셔서 감사합니다!! 👍

*/
function rob(nums: number[]): number {
if (nums.length === 1) return nums[0];
if (nums.length === 2) return Math.max(nums[0], nums[1]);
Copy link
Contributor

Choose a reason for hiding this comment

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

nums.length 에 따른 예외처리도 처음부터 넣어서 안전하게 처리해주셨네요
dp배열을 없애고 필요한 값만 저장해 공간복잡도를 개선하는 부분이 참 인상적이네요! 많이배웠습니다

numMap.set(num, (numMap.get(num) ?? 0) + 1);
}

const storedArr: number[][] = Array(nums.length + 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

저는 Map으로 중복을 제거하고, entries를 사용해 배열화한다음 sorting 해서 출력해주는것밖에 떠오르지않았는데
따로 정렬을 사용하지않고,빈도카운팅을해서 배열에 추가하는식으로 접근하신게 너무 신기했어요!
친절하게 주석을 달아주셔서 처음보는 개념인데도 이해가 쉬웠습니다. 감사합니다

Copy link
Contributor Author

Choose a reason for hiding this comment

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

저도 sorting 없이 풀려고 하니까 잘 떠오르지 않더라구요! 😄
O(n)으로 풀고 싶어서 다른 분들 풀이 참고했어요!
더 나은 풀이법 발견하면 넘 신기하더라구요!!

@mmyeon
Copy link
Contributor Author

mmyeon commented Apr 4, 2025

전반적으로 풀이하신 코드들이 가독성이 좋았고, 리뷰어이자 참여자였던 제 풀이보다 시간복잡도와 공간복도 측면에서 훨씬 더 깊이 고민하신 게 느껴졌습니다.

덕분에 저도 앞으로는 코드 작성 시 주석을 활용하고, 복잡도도 더 신경 써야겠다는 생각을 하게 되었어요.

이번 리뷰는 오히려 학습의 기회가 된 느낌이라 조금 죄송한 마음이 들지만..ㅎㅎ 한 주 동안 정말 고생 많으셨습니다! 🙏

안녕하세요! @Moonjonghoo 님! 반갑습니다 😄
주석 작성하는 거 정말 추천드려요. 확실히 복잡도에 대해서 더 많이 고민하게 해주는 것 같아요!!
리뷰 꼼꼼히 해주셔서 정말 감사합니다. 큰 도움이 되었어요 !
이번 주 풀이하느라 넘 고생 많으셨고, 다음 주도 파이팅입니다!!!

@mmyeon mmyeon merged commit c469285 into DaleStudy:main Apr 4, 2025
1 check passed
@github-project-automation github-project-automation bot moved this from In Review to Completed in 리트코드 스터디 4기 Apr 4, 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.

3 participants