-
-
Notifications
You must be signed in to change notification settings - Fork 195
[Leo] 7th Week solutions #135
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
파이썬은 제게 생소함에도 불구하고, 코드를 읽는데 편안하고 어렵지 않았습니다. |
@@ -0,0 +1,12 @@ | |||
class Solution: | |||
def isValidBST(self, root: Optional[TreeNode]) -> bool: |
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.
Typescript 처럼, 반환 타입을 지정할 수 있는 코드들이 흥미로웠습니다.
확실히 타입을 지정하니 가독성도 올라가고 훨씬 좋네요!
for i in range(n): | ||
right = right.next | ||
|
||
if not right: return head.next |
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.
JS와 다르게 아주 간단히 not 연산자만으로 조건을 확인하고 반환할 수 있다는 점이 좋네요!
def helper(node, low, high): | ||
if not node: | ||
return True | ||
if not (low < node.val < high): | ||
return False | ||
return helper(node.left, low, node.val) and helper(node.right, node.val, high) |
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 함수를 활용하여 모듈화를 하신 점, 너무 좋은 것 같습니다!
No description provided.