simple and fast java solution


  • 0
    K
    public int sumOfLeftLeaves(TreeNode root) {
            int sum=0;
            if(root==null||root.left==null&&root.right==null)return 0;
            if(root.left!=null&&root.left.left==null&&root.left.right==null)sum+=root.left.val;
            return sum+sumOfLeftLeaves(root.left)+sumOfLeftLeaves(root.right);}
    

Log in to reply
 

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