Skip to content

Conversation

gitsunmin
Copy link
Contributor

답안 제출 문제

체크 리스트

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

@gitsunmin gitsunmin requested a review from EgonD3V October 12, 2024 05:49
@gitsunmin gitsunmin self-assigned this Oct 12, 2024
@gitsunmin gitsunmin requested a review from a team as a code owner October 12, 2024 05:49
@github-actions github-actions bot added the ts label Oct 12, 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.

좋은 풀이 감사합니다. 다음 주도 파이팅.

let right = nums.length - 1;

while (left < right) {
const mid = Math.floor((left + right) / 2);
Copy link
Contributor

Choose a reason for hiding this comment

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

굳이 floor은 안사용하셔도 괜찮을 것 같습니다. 이분탐색에서 while문에 등호를 넣거나 if나 else에서 등호를 넣거나 테스트 해보시면 좋을 것 같습니다.

Comment on lines +16 to +30
function hasCycle(head: ListNode | null): boolean {
if (!head || !head.next) {
return false;
}

let slow: ListNode | null = head;
let fast: ListNode | null = head.next;

while (slow !== fast) {
if (!fast || !fast.next) return false;
slow = slow!.next;
fast = fast.next.next;
}

return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

코드 리뷰를 하면서 드는 생각인데 union-find로도 풀어볼 걸 그랬네요

const directions = [[1, 0], [-1, 0], [0, 1], [0, -1]];

function dfs(r: number, c: number, visited: boolean[][], prevHeight: number) {
if (r < 0 || c < 0 || r >= m || c >= n || visited[r][c] || heights[r][c] < prevHeight) {
Copy link
Contributor

Choose a reason for hiding this comment

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

저도 귀찮아서 한 줄로 쓰기는 하는데, 리뷰어의 입장에서 코드 스멜이나 단축 평가를 고려하면 적절한 조건들로 나누는 게 좋을 것 같습니다. 이 경우는 index error가 일어나지 않을 r, c를 한정하기 위해 순서가 어쩔 수 없지만...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lymchgmk
이야기 감사합니다! 코드 스멜도 신경써볼게요!

@gitsunmin gitsunmin merged commit 0228570 into DaleStudy:main Oct 13, 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