diff --git a/problems/0102.二叉树的层序遍历.md b/problems/0102.二叉树的层序遍历.md index df1790c3..eca4acf4 100644 --- a/problems/0102.二叉树的层序遍历.md +++ b/problems/0102.二叉树的层序遍历.md @@ -421,9 +421,10 @@ var levelOrderBottom = function(root) { node.left&&queue.push(node.left); node.right&&queue.push(node.right); } - res.push(curLevel); + // 从数组前头插入值,避免最后反转数组,减少运算时间 + res.unshift(curLevel); } - return res.reverse(); + return res; }; ```