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

[Flynn] Week7 #486

Merged
merged 7 commits into from
Sep 26, 2024
Merged

[Flynn] Week7 #486

merged 7 commits into from
Sep 26, 2024

Conversation

obzva
Copy link
Contributor

@obzva obzva commented Sep 23, 2024

답안 제출 문제

체크 리스트

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

@obzva obzva marked this pull request as ready for review September 25, 2024 18:27
@obzva obzva requested a review from a team as a code owner September 25, 2024 18:27
Copy link
Contributor

@kjb512 kjb512 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 +34 to +35
matrix[r][0] = 0;
matrix[0][c] = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

기존 배열을 사용해서 기록하면 O(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.

저도 처음엔 O(MN), O(M + N) 공간복잡도 풀이를 했다가 더 나은 방법은 없을까 다른 사람들 솔루션을 구경하다가 배워 온 것 입니다 헤헤

@obzva
Copy link
Contributor Author

obzva commented Sep 26, 2024

@kjb512 이번 문제들이 풀이 설명에 딱히 길게 할 말이 없어서 대강 적었는데 전달에 부족함이 없어서 다행입니다 진범님 ㅎㅎ 늘 정성스런 리뷰 감사합니다

Comment on lines +45 to +48
if (0 <= next.first && next.first < m && 0 <= next.second && next.second < n) {
if (visit[next.first][next.second] == false && grid[next.first][next.second] == '1') {
q.push(next);
visit[next.first][next.second] = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

if문이 해당 조건에 충족시 depth가 들어가게 되는데, 조건에 불충분시 for문을 continue 하는 방법으로 하면 어떨까요?
저는 first, second가 범위 밖에 있으면 바로 continue해서 다음으로 넘어가는 방식을 사용해서 depth를 줄이고 가독성이 높아진다고 생각해서요 :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

좋은 의견 감사합니닷!
요거는 살짝 스타일의 차이인 것 같아서 그대로 두겠습니다
저는 특정 조건일 때 연산하기특정 조건일 때는 연산 안 하고 넘기기보다 더 좋아서 저런 식으로 하고 있습니다
depth는 스타일에 따라 더 읽기 까다로울 수도 있겠네요 ㅎㅎ ㅜ

root->next = head;
// root - a - b - c - d

ListNode* p = head;
Copy link
Contributor

Choose a reason for hiding this comment

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

p 사용 대신 head 자체를 사용해서 풀 수 있을지 궁금합니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

네 토니님 말씀대로 p를 선언하는 대신 head를 그대로 이용할 수 있습니다
p를 굳이 새로 선언해서 사용하는 이유는 q 변수의 변수명이 적절한 것이 생각나지 않아서..
head -> p로 새로 선언하고 그 다음 변수에 q라고 이름을 붙여주었습니다 ㅎㅎㅎ

Comment on lines +40 to +50
for (int r = 1; r < m; ++r) {
if (!matrix[r][0]) {
for (int c = 1; c < n; ++c) matrix[r][c] = 0;
}
}

for (int c = 1; c < n; ++c) {
if (!matrix[0][c]) {
for (int r = 1; r < m; ++r) matrix[r][c] = 0;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

위에서 이미 double for loop이 사용되었기 때문에, 이 부분도 이중 포문으로 처리 하셔도 될 것 같아요! 근데 나눠두는게 이해하기 더 직관적이고 이해하기 편한것 같이 보이네요!

Copy link
Contributor Author

@obzva obzva Sep 26, 2024

Choose a reason for hiding this comment

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

제가 잘 이해를 못했는데, double loop 예시 코드와 그렇게 바꿨을 때의 이점을 설명 부탁드려도 될까요? :)

Copy link
Contributor

@TonyKim9401 TonyKim9401 left a comment

Choose a reason for hiding this comment

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

Flynn님 코드는 언제봐도 설명이 너무 정갈하셔서... GOAT 십니다. 고생하셨습니다! 💯

@obzva
Copy link
Contributor Author

obzva commented Sep 26, 2024

@TonyKim9401 과찬이십니다 부끄럽습니다 ㅎㅎㅎ.. 감사합니다~!

@obzva obzva merged commit d94393f into DaleStudy:main Sep 26, 2024
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.

3 participants