mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 03:34:02 +08:00
Merge pull request #1509 from coderwei99/master
fix: 修改第111题二叉树最小深度js代码
This commit is contained in:
@ -372,7 +372,7 @@ var minDepth1 = function(root) {
|
||||
// 到叶子节点 返回 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);
|
||||
return Math.min(minDepth(root.left), minDepth(root.right)) + 1;
|
||||
|
Reference in New Issue
Block a user