This commit is contained in:
高阔
2023-09-09 10:23:43 +08:00
parent bf51d4730d
commit 839afd119b

View File

@ -173,12 +173,12 @@ private:
int result;
void getdepth(TreeNode* node, int depth) {
// 函数递归终止条件
if (root == nullptr) {
if (node == nullptr) {
return;
}
// 中,处理逻辑:判断是不是叶子结点
if (root -> left == nullptr && root->right == nullptr) {
res = min(res, depth);
if (node -> left == nullptr && node->right == nullptr) {
result = min(result, depth);
}
if (node->left) { // 左
getdepth(node->left, depth + 1);