Skip to content
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

[YeomChaeeun] Week 4 #818

Merged
merged 2 commits into from
Jan 5, 2025
Merged

[YeomChaeeun] Week 4 #818

merged 2 commits into from
Jan 5, 2025

Conversation

YeomChaeeun
Copy link
Contributor

@YeomChaeeun YeomChaeeun commented Dec 30, 2024

답안 제출 문제

체크 리스트

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

@YeomChaeeun YeomChaeeun requested a review from a team as a code owner December 30, 2024 08:42
@github-actions github-actions bot added the ts label Dec 30, 2024
@YeomChaeeun YeomChaeeun requested a review from minji-go December 30, 2024 08:42
Copy link
Contributor

@HC-kang HC-kang left a comment

Choose a reason for hiding this comment

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

@YeomChaeeun 님, 2024년 한해 고생 많으셨습니다.
2025년에도 완주까지 꼭 참여해주시면 좋겠습니다!
아직 풀이중이시니 코멘트만 남기겠습니다. 새해 복 많이 받으세요!


nums.sort((a, b) => a - b)

for(let i = 0; i < nums.length; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

오,, 처음엔 순회 범위가 잘못된줄 알았는데요,
혹시 마지막 숫자가 비어있는 경우를 nums[i + 1]undefined가 나오도록 해서 false를 유도하고 nums[i] + 1을 유도하신걸까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

넵 맞습니다!
[0, 1] 이 예시라면 nums[1] + 1 !== undefined 가 되어서
최종적으론 nums[1] + 1 인 2가 결과값으로 나오게 됩니다!

Copy link
Contributor

@minji-go minji-go left a comment

Choose a reason for hiding this comment

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

안녕하세요! 저랑 풀이가 비슷한 듯 달라서 흥미롭기도 하고 많이 배웠습니다👍
새해 복 많이 받으세요 :)

Comment on lines +13 to +17
for (const coin of coins) {
for (let i = coin; i <= amount; i++) {
dp[i] = Math.min(dp[i], dp[i - coin] + 1)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

저는 이중 for문에서 바깥쪽 for문을 amount로 했는데,
바깥쪽 for문을 coin으로 하면 더 간결한 코드로 같은 결과를 도출할 수 있어서 좋은 것 같습니다!

* @param list2
*/
function mergeTwoLists(list1: ListNode | null, list2: ListNode | null): ListNode | null {
if(!(list1 && list2)) return list1 || list2
Copy link
Contributor

Choose a reason for hiding this comment

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

타입스크립트는 논리 연산자를 활용하여 간결하게 값 선택 및 조건 처리를 할 수 있는게 좋은 것 같네요!

Comment on lines +22 to +28
if(list1.val < list2.val) {
list1.next = mergeTwoLists(list1.next, list2);
return list1
} else {
list2.next = mergeTwoLists(list2.next, list1);
return list2
}
Copy link
Contributor

Choose a reason for hiding this comment

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

저는 객체 값을 직접 비교하는 방법을 썼는데 재귀를 쓰니까 새로운 객체를 생성할 필요가 없다는게 좋은 것 같습니다!

Comment on lines +15 to +19
for(let i = 0; i < nums.length; i++) {
if(nums[0] !== 0) return 0
if(nums[i] + 1 !== nums[i + 1])
return nums[i] + 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[i]를 swap하는 방식 혹은 bit연산을 활용해서 O(N)의 시간복잡도로 줄여보는 것도 좋을 것 같아요

Copy link
Contributor

@obzva obzva left a comment

Choose a reason for hiding this comment

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

한 주 수고하셨습니다

@YeomChaeeun
Copy link
Contributor Author

@HC-kang @minji-go
리뷰 감사합니다 ^^
새해복 많이받으세요!!👍

@YeomChaeeun YeomChaeeun merged commit 8a7472d into DaleStudy:main Jan 5, 2025
1 check passed
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.

4 participants