Merge pull request #782 from Jerry-306/patch-15

修改 0107 二叉树层序遍历II JavaScript解法
This commit is contained in:
程序员Carl
2021-09-29 10:36:45 +08:00
committed by GitHub

View File

@ -421,9 +421,10 @@ var levelOrderBottom = function(root) {
node.left&&queue.push(node.left); node.left&&queue.push(node.left);
node.right&&queue.push(node.right); node.right&&queue.push(node.right);
} }
res.push(curLevel); // 从数组前头插入值,避免最后反转数组,减少运算时间
res.unshift(curLevel);
} }
return res.reverse(); return res;
}; };
``` ```