mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-07 15:45:40 +08:00
@ -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);
|
||||
|
Reference in New Issue
Block a user