Why am I answer is incorrect


  • 0
    G
    public class Solution {
        public int sumOfLeftLeaves(TreeNode root) {
            int res=0;
            sumLeft(root,res);
            return res;
        }
        private void sumLeft(TreeNode root, int res){
            if (root==null||(root.left==null&&root.right==null)) return;
            if(root.left!=null){
                if(root.left.left==null&&root.left.right==null) res=res+root.left.val;
                sumLeft(root.left, res);
            }
            if(root.right!=null) sumLeft(root.right,res);
        }
    }
    

    Thanks?


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.