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

[kayden] Week 09 Solutions #526

Merged
merged 1 commit into from
Oct 12, 2024
Merged

[kayden] Week 09 Solutions #526

merged 1 commit into from
Oct 12, 2024

Conversation

kjb512
Copy link
Contributor

@kjb512 kjb512 commented Oct 11, 2024

답안 제출 문제

너무 늦게 올렸네요.. 면접이 많이 잡혀서 급하게 풀고 올립니다!

체크 리스트

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

@kjb512 kjb512 self-assigned this Oct 11, 2024
@github-actions github-actions bot added the py label Oct 11, 2024
@kjb512 kjb512 requested a review from EgonD3V October 11, 2024 18:57
@kjb512 kjb512 marked this pull request as ready for review October 11, 2024 18:58
@kjb512 kjb512 requested a review from a team as a code owner October 11, 2024 18:58
@kjb512 kjb512 changed the title Adds Solutions [kayden] Week 09 Solutions Oct 11, 2024
Copy link
Contributor

@EgonD3V EgonD3V left a comment

Choose a reason for hiding this comment

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

좋은 풀이 감사합니다. 이번 주도 고생 많으셨습니다.

# 공간복잡도: O(N)
def hasCycle(self, head: Optional[ListNode]) -> bool:

visited = set()
Copy link
Contributor

Choose a reason for hiding this comment

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

이미 방문한 node를 재방문하면 cycle이 존재한다는 풀이가 명확해서 좋은 것 같습니다. Follow up에 공간복잡도를 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.

리뷰 감사합니다! 공간복잡도를 줄이는 방법도 찾아봐야겠네요!

Comment on lines +6 to +13
prev = 0
answer = float('-inf')
for num in nums:
if prev + num > num:
prev += num
else:
prev = num
answer = max(answer, prev)
Copy link
Contributor

Choose a reason for hiding this comment

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

이 문제의 경우 유명한게 Kadane 알고리즘도 있지만, 면접에서 divide and conquer로도 풀어보라는 경우가 많다고 하더라고요 참고해보시면 좋을 것 같습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

여러 방법 알려주셔서 감사합니다! 해당 부분들도 공부해 보겠습니다!

@kjb512 kjb512 merged commit 359ae2c into DaleStudy:main Oct 12, 2024
3 checks 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