refactor: 0102.二叉树的层序遍历.md

This commit is contained in:
qiufeihong2018
2024-04-29 16:12:38 +08:00
parent f755ecc5fc
commit 5ee2f42edb
2 changed files with 22 additions and 20 deletions

View File

@ -693,7 +693,8 @@ func levelOrderBottom(root *TreeNode) [][]int {
```javascript ```javascript
var levelOrderBottom = function (root) { var levelOrderBottom = function (root) {
let res = [], queue = []; let res = [],
queue = [];
queue.push(root); queue.push(root);
while (queue.length && root !== null) { while (queue.length && root !== null) {
// 存放当前层级节点数组 // 存放当前层级节点数组
@ -713,6 +714,7 @@ var levelOrderBottom = function(root) {
} }
return res; return res;
}; };
``` ```
#### TypeScript: #### TypeScript:

View File

@ -71,7 +71,7 @@
有递归的地方就有回溯,那么回溯在哪里呢? 有递归的地方就有回溯,那么回溯在哪里呢?
递归函数的下面,例如如下代码: 就递归函数的下面,例如如下代码:
```cpp ```cpp
void dfs(参数) { void dfs(参数) {