Merge pull request #2533 from VoxDai/patch-1
Update 0111.二叉树的最小深度.md / Fix typo
This commit is contained in:
commit
56a7c68610
|
|
@ -64,7 +64,7 @@
|
|||
|
||||
代码如下:
|
||||
|
||||
```
|
||||
```CPP
|
||||
int getDepth(TreeNode* node)
|
||||
```
|
||||
|
||||
|
|
@ -74,14 +74,14 @@ int getDepth(TreeNode* node)
|
|||
|
||||
代码如下:
|
||||
|
||||
```
|
||||
```CPP
|
||||
if (node == NULL) return 0;
|
||||
```
|
||||
|
||||
3. 确定单层递归的逻辑
|
||||
|
||||
这块和求最大深度可就不一样了,一些同学可能会写如下代码:
|
||||
```
|
||||
```CPP
|
||||
int leftDepth = getDepth(node->left);
|
||||
int rightDepth = getDepth(node->right);
|
||||
int result = 1 + min(leftDepth, rightDepth);
|
||||
|
|
|
|||
Loading…
Reference in New Issue