Skip to content

Conversation

@prgmr99
Copy link
Member

@prgmr99 prgmr99 commented Nov 10, 2025

답안 제출 문제

작성자 체크 리스트

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

검토자 체크 리스트

Important

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

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

@prgmr99 prgmr99 moved this from Solving to In Review in 리트코드 스터디 6기 Nov 14, 2025
@yuhyeon99
Copy link
Contributor

문제 풀이 고생하셨습니다 ㅎㅎ

하나씩 리뷰 남길게요!!

Copy link
Contributor

Choose a reason for hiding this comment

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

중복을 제거한 Set 객체의 길이와 기존 배열의 길이를 비교하셨네요!!
한 눈에 봤을 때 이해가 잘 되어서 좋았습니다 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

감사합니다 :)

}

return maxMoneyAtPrevHouse;
};
Copy link
Contributor

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 집까지의 최대값 그대로
)

이런 방식으로 구현하신게 맞을까요?

추가로 변수명을 직관적으로 잘 적어주셔서 이해하기 더 편했습니다👍

Copy link
Member Author

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);
Copy link
Contributor

Choose a reason for hiding this comment

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

저는 이 부분에서 별도로 변수에 할당을 하진 않았는데 배열이 어떤 상태인지 생각할 때 덜 헷갈리게하려면 이렇게 작성하는 습관을 들이는게 좋을거같네요..!

Copy link
Member Author

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;
Copy link
Contributor

Choose a reason for hiding this comment

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

이 부분이 최대 길이를 갱신해주는 부분이군요!
저는 길이를 누적시키다 문제 조건에 맞지 않을 때 갱신해줬는데
좋은 방법 같습니다 ㅎㅎ

}
}

const mapToArr = [...numMap.entries()];
Copy link
Contributor

Choose a reason for hiding this comment

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

이터러블의 entries 함수와 스프레드 연산자로 배열을 만드셨네요.
좋은 것 같아요 ㅎㅎ 나머지는 저와 동일한 방법으로 푸셔서 이견 없습니다!

Copy link
Contributor

Choose a reason for hiding this comment

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

깔끔하게 잘 푸신 것 같아요! 고생하셨습니다~

Copy link
Member Author

Choose a reason for hiding this comment

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

감사합니다~~
1주차 고생하셨습니다~~

Copy link
Contributor

@yuhyeon99 yuhyeon99 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다~!!

@prgmr99 prgmr99 merged commit 3c6ad8e into DaleStudy:main Nov 15, 2025
1 check passed
@github-project-automation github-project-automation bot moved this from In Review to Completed in 리트코드 스터디 6기 Nov 15, 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