Root Equals Sum of Children

EasyTreeBinary Tree

Solution

import { TreeNode } from '@algorithm/lib';
 
export function checkTree(root: TreeNode | null): boolean {
  return !root || root.val === root.left!.val + root.right!.val;
}