My Javascript Solution


  • 0
    R
    var levelOrderBottom = function(root) {
        var result = [];
        var index = 0;
        var recursive = function(node, index){
            if(!node) return;
            if(index >= result.length) result[index] = [];
            result[index].push(node.val);
            recursive(node.left, index + 1);
            recursive(node.right, index + 1);
        }
        recursive(root, 0);
        return result.reverse()
    };

Log in to reply
 

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