Merge pull request #2534 from VoxDai/patch-2

Update 0222.完全二叉树的节点个数.md / Fix Typo
This commit is contained in:
程序员Carl
2024-05-15 10:26:15 +08:00
committed by GitHub

View File

@ -54,7 +54,7 @@
1. 确定递归函数的参数和返回值参数就是传入树的根节点返回就返回以该节点为根节点二叉树的节点数量所以返回值为int类型。
代码如下:
```
```CPP
int getNodesNum(TreeNode* cur) {
```
@ -62,7 +62,7 @@ int getNodesNum(TreeNode* cur) {
代码如下:
```
```CPP
if (cur == NULL) return 0;
```
@ -70,7 +70,7 @@ if (cur == NULL) return 0;
代码如下:
```
```CPP
int leftNum = getNodesNum(cur->left); // 左
int rightNum = getNodesNum(cur->right); // 右
int treeNum = leftNum + rightNum + 1; // 中