-
-
Notifications
You must be signed in to change notification settings - Fork 195
[Raft] Week 01 solutions #318
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
Conversation
Projects 달아두려고해도 Add할 수가 없는데 확인 가능 할까요? |
아래 저희 디스코드 채널 내 메시지 참고해보시면, leetcode 팀 초대 수락을 안하셨을 가능성이 높은데, 한 번 확인해보시겠어요? |
@yolophg 감사합니다 :) |
@coloryourlife 안녕하세요! (저도 받은 코멘트 입니다 ㅎㅎ) 시간 복잡도, 공간 복잡도도 같이 주석으로 남겨주시면 좋을 것 같습니다~~ |
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.
수고하셨습니다. 모임 전까지 PR 병합 부탁드리겠습니다.
r += 1 | ||
return count | ||
# T: O(n^2) | ||
# S: O(n^2) |
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^2)
으로 분석 되셨는지 설명 좀 부탁드려도 될까요?
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.
단순하게 count를 n^2 번만큼 저장한다고 생각했는데 다시보니 O(n) 같아보이네요..!
class Solution: | ||
def kthSmallest(self, root: Optional[TreeNode], k: int) -> int: | ||
stack = [] | ||
|
||
while True: | ||
while root: | ||
stack.append(root) | ||
root = root.left | ||
root = stack.pop() | ||
k -= 1 | ||
if not k: | ||
return root.val | ||
root = root.right |
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.
와, 이 풀이 완전 신선합니다. 혹시 이번 주 모임에 참석하신다면 다른 분들께 답안 소개해주시면 좋을 것 같습니다.
No description provided.