Merge pull request #1509 from coderwei99/master
fix: 修改第111题二叉树最小深度js代码
This commit is contained in:
commit
98db90f081
|
|
@ -372,7 +372,7 @@ var minDepth1 = function(root) {
|
||||||
// 到叶子节点 返回 1
|
// 到叶子节点 返回 1
|
||||||
if(!root.left && !root.right) return 1;
|
if(!root.left && !root.right) return 1;
|
||||||
// 只有右节点时 递归右节点
|
// 只有右节点时 递归右节点
|
||||||
if(!root.left) return 1 + minDepth(root.right);、
|
if(!root.left) return 1 + minDepth(root.right);
|
||||||
// 只有左节点时 递归左节点
|
// 只有左节点时 递归左节点
|
||||||
if(!root.right) return 1 + minDepth(root.left);
|
if(!root.right) return 1 + minDepth(root.left);
|
||||||
return Math.min(minDepth(root.left), minDepth(root.right)) + 1;
|
return Math.min(minDepth(root.left), minDepth(root.right)) + 1;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue