-
-
Notifications
You must be signed in to change notification settings - Fork 247
[jangwonyoon] WEEK04 solutions #1835
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이번 한 주도 고생 많으셨습니다~!
- n: list1의 길이, m: list2의 길이 | ||
|
||
* 공간 복잡도(SC): O(n + m) | ||
- 재귀 호출 시 스택 메모리가 최대 n+m 깊이까지 쌓일 수 있음 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
적어두신 것처럼 재귀로 풀면 콜 스택으로 인해 공간 복잡도가 O(n + m)이 됩니다! 그래서 저는 링크드리스트 문제는 반복문으로도 한 번 더 풀어보는 편인데요, 코드가 조금 더 복잡해지기는 하지만 공간 복잡도를 O(1)으로 줄일 수 있기 때문입니다. 여유가 되신다면 반복문으로도 풀어보시는 걸 추천드려요~!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오오 감사합니다!! 반복문으로더 풀어볼게요
* | ||
* 문제 풀이 방법: | ||
* 1. 배열을 이진 탐색으로 탐색 | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
각 풀이별로 복잡도 분석과 풀이법을 정리해주셔서 리뷰어 입장에서도 이해가 쉬웠고, 풀이하시는 과정에서도 공부가 많이 되셨을 것 같습니다!
// 2) 가드: 범위/문자/방문 상태 확인 | ||
if (r < 0 || r >= rows || c < 0 || c >= cols) return false; | ||
if (board[r][c] !== word[idx]) return false; | ||
if (board[r][c] === '#') return false; // 이미 방문했으면 탈락 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저는 주로 dfs에서 조건을 확인할 때 여러 조건들을 모두 or
로 연결하곤 했었는데요, 각 조건이 각각 라인별로 적혀있으니 오히려 훨씬 가독성도 좋고 디버깅하기가 쉬워보이네요! 덕분에 배워갑니다~!
답안 제출 문제
작성자 체크 리스트
In Review
로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!