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

[gitsunmin] WEEK11 Solutions #555

Merged
merged 5 commits into from
Oct 27, 2024
Merged

[gitsunmin] WEEK11 Solutions #555

merged 5 commits into from
Oct 27, 2024

Conversation

gitsunmin
Copy link
Contributor

답안 제출 문제

체크 리스트

  • PR을 프로젝트에 추가하고 Week를 현재 주차로 설정해주세요.
  • 바로 앞에 PR을 열어주신 분을 코드 검토자로 지정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 Status를 In Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

@gitsunmin gitsunmin requested a review from EgonD3V October 26, 2024 15:22
@gitsunmin gitsunmin self-assigned this Oct 26, 2024
@gitsunmin gitsunmin requested a review from a team as a code owner October 26, 2024 15:22
@github-actions github-actions bot added the ts label Oct 26, 2024
Copy link
Contributor

@EgonD3V EgonD3V 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 +19 to +26
// 1. 중간 지점 찾기 (Floyd’s Tortoise and Hare)
let slow: ListNode | null = head;
let fast: ListNode | null = head;

while (fast && fast.next) {
slow = slow!.next;
fast = fast.next.next;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

전에 cycle 찾을 때 봤던 알고리즘인데, 이러게 중간 지점 찾는 용도로도 사용할 수 있군요

Comment on lines +40 to +52
let first: ListNode | null = head;
let second: ListNode | null = prev;

while (second && second.next) {
const temp1 = first!.next;
const temp2 = second.next;

first!.next = second;
second.next = temp1;

first = temp1;
second = temp2;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

저는 전체 리스트를 뒤집어 놓고, 원래 리스트랑 뒤집은 리스트랑 같이 조회하면서 병합시켰는데, 이렇게하면 메모리를 아낄 수 있는 좋은 풀이인 것 같습니다.

@gitsunmin gitsunmin merged commit 2208dd5 into DaleStudy:main Oct 27, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

2 participants