Skip to content

Conversation

obzva
Copy link
Contributor

@obzva obzva commented Sep 30, 2024

답안 제출 문제

체크 리스트

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

@github-actions github-actions bot added the c++ label Sep 30, 2024
@obzva obzva requested a review from jdalma September 30, 2024 06:19
while (lo < hi) {
int mid = lo + (hi - lo) / 2;

if (can_make_valid_substring(s, mid, k)) lo = mid + 1;
Copy link
Member

Choose a reason for hiding this comment

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

바이너리 서치로 푸시다니 엄청 신선하네요
end 포인터를 한 칸씩 옮기면서 start 포인터를 움직이는 방식으로 풀었는데, 여기서는 "만들 수 있는 부분 문자열의 길이를 lo로 갱신" 하는 것이 핵심인가 보네요 ㅎㅎ 잘 봤습니다

Copy link
Contributor Author

Choose a reason for hiding this comment

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

저도 아이디어가 안 떠올라서 리트코드의 에디토리얼을 참고했는데, 신선하더라구요 ㅎㅎ 감사합니다
이 풀이보다 시간복잡도 면에서 더 효율적인 풀이가 있긴 하지만요

@obzva obzva marked this pull request as ready for review October 3, 2024 16:20
@obzva obzva requested a review from a team as a code owner October 3, 2024 16:20
@obzva obzva requested a review from jdalma October 4, 2024 11:56
Copy link
Member

@jdalma jdalma 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 43 to 53
while (p != nullptr) {
node->next = p;
p = p->next;
node = node->next;
}

while (q != nullptr) {
node->next = q;
q = q->next;
node = node->next;
}
Copy link
Member

@jdalma jdalma Oct 4, 2024

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

앗 그렇네요 ㅎㅎㅎ 좋은 지적 감사합니다 반영하겠습니다!


/**
* 풀이 2
* - 풀이 1의 DP 전개 과정을 보면 우리한테는 DP 배열 두 행만 필요하다는 걸 알 수 있습니다
Copy link
Member

Choose a reason for hiding this comment

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

오 unique-paths 문제처럼 최적화를 할 수 있었군요.. 잘 봤습니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

네 맞습니다 대부분의 2D 배열을 이용하는 DP 풀이는 이런 식의 공간 복잡도 최적화가 가능합니다 ㅎㅎ

@obzva obzva merged commit db64cd4 into DaleStudy:main Oct 4, 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