public int sumOfLeftLeaves(TreeNode root) {
if(root ==
null)
return 0;
int ans =
0;
if(root.left !=
null) {
if(root.left.left ==
null && root.left.right ==
null) ans += root.left.val;
else ans += sumOfLeftLeaves(root.left);
}
ans += sumOfLeftLeaves(root.right);
return ans;
}
转载请注明原文地址: https://ju.6miu.com/read-25564.html