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

[EGON] Week10 Solutions #542

Merged
merged 7 commits into from
Oct 24, 2024
Merged

[EGON] Week10 Solutions #542

merged 7 commits into from
Oct 24, 2024

Conversation

lymchgmk
Copy link
Contributor

@lymchgmk lymchgmk commented Oct 19, 2024

답안 제출 문제

체크 리스트

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

@lymchgmk lymchgmk added the py label Oct 19, 2024
@lymchgmk lymchgmk self-assigned this Oct 19, 2024
@lymchgmk lymchgmk requested a review from a team as a code owner October 19, 2024 10:59
Copy link
Contributor

@HC-kang HC-kang left a comment

Choose a reason for hiding this comment

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

@lymchgmk 님 항상 체계적인 풀이 잘 보고있습니다
지난주도 고생 많으셨고, 이번 주도 잘 부탁드립니다!

> O(p) + O(c) + O(c + p) ~= o(c + p)

Memory: 17.85 MB (Beats 99.94%)
Space Complexity: O(c)
Copy link
Contributor

Choose a reason for hiding this comment

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

28-30 라인에서 그래프를 저장할 때, c 뿐만 아니라 p도 공간복잡도에 영향을 끼치지 않을까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

감사합니다 dict에서 value에 대해 sc를 생각 못했네요; key의 갯수는 c에 비례하고, value의 모든 원소의 갯수는 p에 비례하니 O(c + p)가 맞을 것 같습니다.

return True

if dp[i] is True:
for jump in range(-nums[i], nums[i] + 1):
Copy link
Contributor

Choose a reason for hiding this comment

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

뒤쪽 방향으로 점프하는 케이스는 굳이 다룰 필요가 있을까요?
이미 현 지점에 도달했다는 의미는, 이전의 모든 칸은 True인 상태가 되었을텐데 말이죠.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

뒤로 돌아가야만 도달할 수 있는 엣지케이스가 있을거라 생각하고 짰는데 말씀하신 부분이 맞는 것 같습니다.

- heap의 크기는 최대 k이므로,
- heappop하는데 O(k * log k)
- heappush하는데 lists를 이루는 list를 이루는 모든 원소들의 총 갯수를 n이라 하면, O(n * log k)
> O(k * log k) + O(k * log k) + O(n * log k) ~= O(max(k, n) * log k) = O(n * log k)
Copy link
Contributor

Choose a reason for hiding this comment

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

22번 라인은 아마 O(logk)인데, 21라인의 k도 포함하신것으로 보이네요. 제가 이해한것이 맞을까요?
24라인의 경우 O(k * log k) + O(k * log k) + O(n * log k)로 산출해주셨는데, 이를 O(max(k, n) * log k)로 단순화하기에는 문제 조건에 k, n에 대한 조건이 명시되어있지 않은것으로 보입니다.
결과적으로 아마도 O((k + n) * log k)로 표현하는것이 적절하지 않을까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

k 포함이 맞습니다. k는 lists의 길이이고 n은 lists의 원소인 list의 원소 모두의 갯수로 최종적으로 병합된 list의 node의 갯수와 같다면, n = a * k이고 a는 lists의 원소인 list의 평균길이라 생각해서 저렇게 합쳤는데, 지금 보니 역으로도 설명 가능할 것 같습니다.
max(k, n) = max(k, a * k) = a * k = n ~= k

Copy link
Contributor

Choose a reason for hiding this comment

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

아, n이 이미 a라는 변수를 통해 내부적으로 k를 포함하고 있다고 볼 수 있었네요. 설명해주셔서 감사합니다!

@lymchgmk lymchgmk merged commit 64495db into DaleStudy:main Oct 24, 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.

2 participants