Leetcode in Java && Oracle
422 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
image_2022-04-01_15-06-04.png
36.4 KB
#N404. Sum of Left Leaves
problem link

#solution
class Solution {
public int sumOfLeftLeaves(TreeNode root) {
int res=0;
if(root == null) return 0;
if(root.left != null){
if(root.left.left == null && root.left.right == null) res += root.left.val;
else res += sumOfLeftLeaves(root.left);
}

res+=sumOfLeftLeaves(root.right);

return res;
}
}