commit
410bb6824e
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue