-
-
Notifications
You must be signed in to change notification settings - Fork 304
[prgmr99] WEEK 01 solutions #1987
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
Conversation
|
문제 풀이 고생하셨습니다 ㅎㅎ 하나씩 리뷰 남길게요!! |
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.
중복을 제거한 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.
감사합니다 :)
| } | ||
|
|
||
| return maxMoneyAtPrevHouse; | ||
| }; |
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.
간결하게 잘 푸신 것 같아요!
전 집까지의 누적합과 현재 집 + 전전집의 누적합을 비교해서 더 큰 값을 선택하도록 구현해주신걸로 이해했는데 맞을까요?
그리고 제가 이 문제는 제대로 이해하지 못해서 더 공부해봤는데
다음과 같은 식을 알게됐어요.
currentMax = max(
nums[i] + DP[i-2], // 이번 집을 털면 → i-1 집은 못 턴다
DP[i-1] // 이번 집을 안 털면 → i-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.
넵! 맞습니다!
말씀해주신 currentMax가 i번째 집까지 털었을 때의 최댓값을 의미한다고 이해해주시면 될 것 같습니다..!
|
|
||
| if (nums.length === 0) return 0; | ||
|
|
||
| const sortedNums = nums.sort((a, b) => a - b); |
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.
저는 이 부분에서 별도로 변수에 할당을 하진 않았는데 배열이 어떤 상태인지 생각할 때 덜 헷갈리게하려면 이렇게 작성하는 습관을 들이는게 좋을거같네요..!
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.
바로 하셔도 사실 큰 문제는 없어서,
두 방식 다 좋은 것 같아요!!
| result += 1; | ||
|
|
||
| if (maxLength < result) { | ||
| maxLength = result; |
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.
이 부분이 최대 길이를 갱신해주는 부분이군요!
저는 길이를 누적시키다 문제 조건에 맞지 않을 때 갱신해줬는데
좋은 방법 같습니다 ㅎㅎ
| } | ||
| } | ||
|
|
||
| const mapToArr = [...numMap.entries()]; |
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.
이터러블의 entries 함수와 스프레드 연산자로 배열을 만드셨네요.
좋은 것 같아요 ㅎㅎ 나머지는 저와 동일한 방법으로 푸셔서 이견 없습니다!
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.
깔끔하게 잘 푸신 것 같아요! 고생하셨습니다~
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.
감사합니다~~
1주차 고생하셨습니다~~
yuhyeon99
left a comment
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.
고생하셨습니다~!!
답안 제출 문제
작성자 체크 리스트
In Review로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!