728x90
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def checkTree(self, root: Optional[TreeNode]) -> bool:
return root.val == (root.left.val + root.right.val)
https://leetcode.com/problems/root-equals-sum-of-children/
728x90
'IT > 코딩테스트' 카테고리의 다른 글
[Leetcode] 1512. Number of Good Pairs (0) | 2024.02.07 |
---|---|
[Leetcode] 2671. Frequency Tracker (0) | 2024.02.07 |
[Leetcode] 1002. Find Common Characters (0) | 2024.02.04 |
[Leetcode] 2703. Return Length of Arguments Passed (0) | 2024.02.02 |
[Leetcode] 9. Palindrome Number (0) | 2024.02.02 |