Class Solution

java.lang.Object
g0401_0500.s0404_sum_of_left_leaves.Solution

public class Solution extends Object
404 - Sum of Left Leaves.<p>Easy</p> <p>Given the <code>root</code> of a binary tree, return the sum of all left leaves.</p> <p><strong>Example 1:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2021/04/08/leftsum-tree.jpg" alt="" /></p> <p><strong>Input:</strong> root = [3,9,20,null,null,15,7]</p> <p><strong>Output:</strong> 24</p> <p><strong>Explanation:</strong> There are two left leaves in the binary tree, with values 9 and 15 respectively.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> root = [1]</p> <p><strong>Output:</strong> 0</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>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • sumOfLeftLeaves

      public int sumOfLeftLeaves(TreeNode root)