-
Notifications
You must be signed in to change notification settings - Fork 126
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
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.
좋은 풀이 감사합니다. 이번 주도 고생 많으셨습니다.
# 공간복잡도: O(N) | ||
def hasCycle(self, head: Optional[ListNode]) -> bool: | ||
|
||
visited = set() |
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.
이미 방문한 node를 재방문하면 cycle이 존재한다는 풀이가 명확해서 좋은 것 같습니다. Follow up에 공간복잡도를 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.
리뷰 감사합니다! 공간복잡도를 줄이는 방법도 찾아봐야겠네요!
prev = 0 | ||
answer = float('-inf') | ||
for num in nums: | ||
if prev + num > num: | ||
prev += num | ||
else: | ||
prev = num | ||
answer = max(answer, prev) |
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.
이 문제의 경우 유명한게 Kadane 알고리즘도 있지만, 면접에서 divide and conquer로도 풀어보라는 경우가 많다고 하더라고요 참고해보시면 좋을 것 같습니다.
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.
여러 방법 알려주셔서 감사합니다! 해당 부분들도 공부해 보겠습니다!
답안 제출 문제
너무 늦게 올렸네요.. 면접이 많이 잡혀서 급하게 풀고 올립니다!
체크 리스트
In Review
로 설정해주세요.