DDSA
Advertisement

2236. Root Equals Sum of Children

2236.cs
C#
public class TreeNode
{
    public int val;
    public TreeNode left;
    public TreeNode right;
    public TreeNode(int val = 0, TreeNode left = null, TreeNode right = null)
    {
        this.val = val;
        this.left = left;
        this.right = right;
    }
}


public class Solution
{
    public bool CheckTree(TreeNode root)
    {
        return root.val == (root.left.val + root.right.val);
    }
}
Advertisement