Java Solution


  • 1
    S
    public int sumOfLeftLeaves(TreeNode root) {
        if (null == root) return 0;
        if (null != root.left && null == root.left.left && null == root.left.right) {
            return root.left.val + sumOfLeftLeaves(root.right);
        }
        return 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.