Javascript solution 12lines


  • 0
    E
    var postorderTraversalHelper = function(root, arr) {
        if (root) {
            postorderTraversalHelper(root.left,arr);
            postorderTraversalHelper(root.right,arr);
            postorderTraversalHelper(null,arr.push(root.val));
        }
    };
    var postorderTraversal = function(root) {
        var arr=[];
        postorderTraversalHelper(root,arr);
        return arr;
    };

Log in to reply
 

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