-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<h2><a href="https://leetcode.com/problems/root-equals-sum-of-children/">2236. Root Equals Sum of Children</a></h2><h3>Easy</h3><hr><div><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> </p> | ||
<p><strong class="example">Example 1:</strong></p> | ||
<img alt="" src="https://assets.leetcode.com/uploads/2022/04/08/graph3drawio.png" style="width: 281px; height: 199px;"> | ||
<pre><strong>Input:</strong> root = [10,4,6] | ||
<strong>Output:</strong> true | ||
<strong>Explanation:</strong> The values of the root, its left child, and its right child are 10, 4, and 6, respectively. | ||
10 is equal to 4 + 6, so we return true. | ||
</pre> | ||
|
||
<p><strong class="example">Example 2:</strong></p> | ||
<img alt="" src="https://assets.leetcode.com/uploads/2022/04/08/graph3drawio-1.png" style="width: 281px; height: 199px;"> | ||
<pre><strong>Input:</strong> root = [5,3,1] | ||
<strong>Output:</strong> false | ||
<strong>Explanation:</strong> The values of the root, its left child, and its right child are 5, 3, and 1, respectively. | ||
5 is not equal to 3 + 1, so we return false. | ||
</pre> | ||
|
||
<p> </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> | ||
</div> |