Solution 1 - Direct Check
Return whether root.val == root.left.val + root.right.val.
""" 2236.1 - Root Equals Sum of Children - Solution 1 - Direct Check """
from typing import Optional
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