We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1810a9a commit 3652d00Copy full SHA for 3652d00
problems/0104.二叉树的最大深度.md
@@ -523,8 +523,8 @@ func maxdepth(root *treenode) int {
523
524
```javascript
525
var maxdepth = function(root) {
526
- if (!root) return root
527
- return 1 + math.max(maxdepth(root.left), maxdepth(root.right))
+ if (root===null) return 0;
+ return 1 + Math.max(maxdepth(root.left), maxdepth(root.right))
528
};
529
```
530
@@ -541,7 +541,7 @@ var maxdepth = function(root) {
541
//3. 确定单层逻辑
542
let leftdepth=getdepth(node.left);
543
let rightdepth=getdepth(node.right);
544
- let depth=1+math.max(leftdepth,rightdepth);
+ let depth=1+Math.max(leftdepth,rightdepth);
545
return depth;
546
}
547
return getdepth(root);
@@ -591,7 +591,9 @@ var maxDepth = function(root) {
591
count++
592
while(size--) {
593
let node = queue.shift()
594
- node && (queue = [...queue, ...node.children])
+ for (let item of node.children) {
595
+ item && queue.push(item);
596
+ }
597
598
599
return count
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments