java.lang.Object
g2201_2300.s2236_root_equals_sum_of_children.Solution

public class Solution extends Object
2236 - Root Equals Sum of Children.<p>Easy</p> <p>You are given the <code>root</code> of a <strong>binary tree</strong> that consists of exactly <code>3</code> nodes: the root, its left child, and its right child.</p> <p>Return <code>true</code> <em>if the value of the root is equal to the <strong>sum</strong> of the values of its two children, or</em> <code>false</code> <em>otherwise</em>.</p> <p><strong>Example 1:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2022/04/08/graph3drawio.png" alt="" /></p> <p><strong>Input:</strong> root = [10,4,6]</p> <p><strong>Output:</strong> true</p> <p><strong>Explanation:</strong> The values of the root, its left child, and its right child are 10, 4, and 6, respectively.</p> <p>10 is equal to 4 + 6, so we return true.</p> <p><strong>Example 2:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2022/04/08/graph3drawio-1.png" alt="" /></p> <p><strong>Input:</strong> root = [5,3,1]</p> <p><strong>Output:</strong> false</p> <p><strong>Explanation:</strong> The values of the root, its left child, and its right child are 5, 3, and 1, respectively.</p> <p>5 is not equal to 3 + 1, so we return false.</p> <p><strong>Constraints:</strong></p> <ul> <li>The tree consists only of the root, its left child, and its right child.</li> <li><code>-100 <= Node.val <= 100</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • checkTree

      public boolean checkTree(TreeNode root)