File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -2629,21 +2629,21 @@ JavaScript:
2629
2629
var minDepth = function(root) {
2630
2630
if (root === null ) return 0 ;
2631
2631
let queue = [root];
2632
- let deepth = 0 ;
2632
+ let depth = 0 ;
2633
2633
while (queue.length) {
2634
2634
let n = queue.length;
2635
- deepth ++ ;
2635
+ depth ++ ;
2636
2636
for (let i= 0 ; i< n; i++ ) {
2637
2637
let node = queue.shift();
2638
- // 如果左右节点都是null,则该节点深度最小
2638
+ // 如果左右节点都是null(在遇见的第一个leaf节点上) ,则该节点深度最小
2639
2639
if (node.left === null && node.right === null ) {
2640
- return deepth ;
2640
+ return depth ;
2641
2641
}
2642
2642
node.left && queue.push(node.left);;
2643
- node.right && queue.push (node.right);
2643
+ node.right && queue.push(node.right);
2644
2644
}
2645
2645
}
2646
- return deepth ;
2646
+ return depth ;
2647
2647
};
2648
2648
```
2649
2649
You can’t perform that action at this time.
0 commit comments