Javascript solution 12 lines (beats 93.15%)


  • 0
    E
    var inorderTraversalHelper = function(root,ary) {
      if (root) {
          inorderTraversalHelper(root.left,ary);
          inorderTraversalHelper(null,ary.push(root.val));
          inorderTraversalHelper(root.right,ary);
      }  
    };
    var inorderTraversal = function(root) {
        var ary=[];
        inorderTraversalHelper(root,ary);
        return ary;
    };

Log in to reply
 

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