-
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
[Lyla] Week 02 solutions #744
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.
2주차도 수고 많으셨습니다 3주차도 화이팅입니다
if nums[left] + nums[right] == target: | ||
result.append([num, nums[left], nums[right]]) | ||
|
||
# skip duplicated numbers ( ex. nums = [-3 0 0 0 3 3] ) | ||
while left < right and nums[left] == nums[left + 1]: | ||
left += 1 | ||
while left < right and nums[right] == nums[right -1]: | ||
right -= 1 | ||
|
||
left += 1 | ||
right -= 1 | ||
elif nums[left] + nums[right] < target: | ||
left += 1 | ||
else: | ||
right -= 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.
가독성을 위해서 left index와 right index가 움직이는 자명한 케이스를 위로 올려서, 가장 중요한 로직이 else문에 위치하게 하면 좋을 것 같습니다
inorder_map = {value: idx for idx, value in enumerate(inorder)} | ||
self.preorder_idx = 0 | ||
|
||
def helper(left: int, right: int) -> Optional[TreeNode]: |
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.
helper 보다는 로직이나 역할이 드러나는 함수명이 좋을 것 같습니다
답안 제출 문제
체크 리스트
In Review
로 설정해주세요.