题目其实指的是left non-inner-node。。
然后就没啥了,BFS DFS应该都可以。。BFS可能麻烦点。
DFS就是遍历前判定下,满足条件的恰好不需要继续go further from that one。。
public class Solution
{
public int sumOfLeftLeaves(TreeNode root)
{
if(root == null) return 0;
if(root.left!=null && root.left.left == null && root.left.right == null)
return root.left.val + sumOfLeftLeaves(root.right);
else return sumOfLeftLeaves(root.left)+sumOfLeftLeaves(root.right);
}
}