IT/코딩테스트
[Leetcode] 2236. Root Equals Sum of Children
이주디
2024. 2. 5. 23:21
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/
LeetCode - The World's Leading Online Programming Learning Platform
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
728x90