-
-
Notifications
You must be signed in to change notification settings - Fork 195
[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
[mmyeon] Week 1 #1144
Conversation
* - 최악의 경우, nums 배열 크기만큼 map에 저장하니까 O(n) | ||
*/ | ||
function twoSum(nums: number[], target: number): number[] { | ||
const seenNumbers = new Map<number, number>(); |
There was a problem hiding this comment.
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 가 필요 없군요
새로운 사실을 알았습니다. 감사합니다.
There was a problem hiding this comment.
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 리뷰어는 제가 수정하겠습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mmyeon 제가 PR을 작성했다가 삭제해서 그렇게 되었습니다.
혼동을 드려 죄송합니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PDKhan
아하 그러셨군요!
리뷰 다시 한번 감사드려요 :)
1주차 문제 풀이 파이팅입니다!!
There was a problem hiding this 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; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
한줄로 깔끔하게 구현해주시고, 복잡도를 다 작성해주셔서 확인하기 편했습니다!
궁금한점은 nums를 Set로 변환할떄, 스프레드 연산자를 사용해서 작성하신 이유가 따로 있을까요?
There was a problem hiding this comment.
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]); |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저는 Map으로 중복을 제거하고, entries를 사용해 배열화한다음 sorting 해서 출력해주는것밖에 떠오르지않았는데
따로 정렬을 사용하지않고,빈도카운팅을해서 배열에 추가하는식으로 접근하신게 너무 신기했어요!
친절하게 주석을 달아주셔서 처음보는 개념인데도 이해가 쉬웠습니다. 감사합니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저도 sorting 없이 풀려고 하니까 잘 떠오르지 않더라구요! 😄
O(n)으로 풀고 싶어서 다른 분들 풀이 참고했어요!
더 나은 풀이법 발견하면 넘 신기하더라구요!!
안녕하세요! @Moonjonghoo 님! 반갑습니다 😄 |
답안 제출 문제
작성자 체크 리스트
In Review
로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!