Nice javascript solution


  • 0
    K

    Recursively look at each node and take value of the it's left node, if the left node has no left or right child

    var sumOfLeftLeaves = function(root) {
        var val = 0;
        if(!root)return 0;
        if (root.left && !root.left.left && !root.left.right) val = root.left.val;
        return val + 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.