-
Notifications
You must be signed in to change notification settings - Fork 120
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] Week 08 #505
[Flynn] Week 08 #505
Conversation
while (lo < hi) { | ||
int mid = lo + (hi - lo) / 2; | ||
|
||
if (can_make_valid_substring(s, mid, k)) lo = mid + 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.
바이너리 서치로 푸시다니 엄청 신선하네요
end 포인터를 한 칸씩 옮기면서 start 포인터를 움직이는 방식으로 풀었는데, 여기서는 "만들 수 있는 부분 문자열의 길이를 lo로 갱신" 하는 것이 핵심인가 보네요 ㅎㅎ 잘 봤습니다
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.
저도 아이디어가 안 떠올라서 리트코드의 에디토리얼을 참고했는데, 신선하더라구요 ㅎㅎ 감사합니다
이 풀이보다 시간복잡도 면에서 더 효율적인 풀이가 있긴 하지만요
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.
수고하셨습니다!
merge-two-sorted-lists/flynn.cpp
Outdated
while (p != nullptr) { | ||
node->next = p; | ||
p = p->next; | ||
node = node->next; | ||
} | ||
|
||
while (q != nullptr) { | ||
node->next = q; | ||
q = q->next; | ||
node = node->next; | ||
} |
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.
제가 C++을 잘 모르지만.. 혹시 while문을 쓰지 않고 아래처럼 참조를 바로 담아주는 것은 어떨까요??
if (l1 != null) node.next = l1
if (l2 != null) node.next = l2
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 | ||
* - 풀이 1의 DP 전개 과정을 보면 우리한테는 DP 배열 두 행만 필요하다는 걸 알 수 있습니다 |
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.
오 unique-paths 문제처럼 최적화를 할 수 있었군요.. 잘 봤습니다!
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.
네 맞습니다 대부분의 2D 배열을 이용하는 DP 풀이는 이런 식의 공간 복잡도 최적화가 가능합니다 ㅎㅎ
답안 제출 문제
체크 리스트
In Review
로 설정해주세요.