mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 23:41:41 +08:00
update
This commit is contained in:
27
leetcode/problem/sum-of-left-leaves.html
Normal file
27
leetcode/problem/sum-of-left-leaves.html
Normal file
@@ -0,0 +1,27 @@
|
||||
<p>Given the <code>root</code> of a binary tree, return <em>the sum of all left leaves.</em></p>
|
||||
|
||||
<p>A <strong>leaf</strong> is a node with no children. A <strong>left leaf</strong> is a leaf that is the left child of another node.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
<img alt="" src="https://assets.leetcode.com/uploads/2021/04/08/leftsum-tree.jpg" style="width: 277px; height: 302px;" />
|
||||
<pre>
|
||||
<strong>Input:</strong> root = [3,9,20,null,null,15,7]
|
||||
<strong>Output:</strong> 24
|
||||
<strong>Explanation:</strong> There are two left leaves in the binary tree, with values 9 and 15 respectively.
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> root = [1]
|
||||
<strong>Output:</strong> 0
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li>The number of nodes in the tree is in the range <code>[1, 1000]</code>.</li>
|
||||
<li><code>-1000 <= Node.val <= 1000</code></li>
|
||||
</ul>
|
Reference in New Issue
Block a user