mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 00:43:04 +08:00
@ -173,12 +173,12 @@ private:
|
|||||||
int result;
|
int result;
|
||||||
void getdepth(TreeNode* node, int depth) {
|
void getdepth(TreeNode* node, int depth) {
|
||||||
// 函数递归终止条件
|
// 函数递归终止条件
|
||||||
if (root == nullptr) {
|
if (node == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 中,处理逻辑:判断是不是叶子结点
|
// 中,处理逻辑:判断是不是叶子结点
|
||||||
if (root -> left == nullptr && root->right == nullptr) {
|
if (node -> left == nullptr && node->right == nullptr) {
|
||||||
res = min(res, depth);
|
result = min(result, depth);
|
||||||
}
|
}
|
||||||
if (node->left) { // 左
|
if (node->left) { // 左
|
||||||
getdepth(node->left, depth + 1);
|
getdepth(node->left, depth + 1);
|
||||||
|
Reference in New Issue
Block a user