leetcode/111.c
2024-09-08 14:39:20 +08:00

17 lines
320 B
C

#include "include/TreeNode.h"
#include <math.h>
int minDepth(struct TreeNode *root)
{
if (!root)
return 0;
if (!root->left || !root->right)
return minDepth(root->left) + minDepth(root->right) + 1;
return fmin(minDepth(root->left), minDepth(root->right)) + 1;
}
int main()
{
return 0;
}