mirror of
https://github.com/TheAlgorithms/C
synced 2025-04-22 05:06:12 +03:00
23 lines
401 B
C
23 lines
401 B
C
/**
|
|
* Definition for a binary tree node.
|
|
* struct TreeNode {
|
|
* int val;
|
|
* struct TreeNode *left;
|
|
* struct TreeNode *right;
|
|
* };
|
|
*/
|
|
|
|
int maxval(int a, int b) {
|
|
if (a > b)
|
|
return a;
|
|
else
|
|
return b;
|
|
}
|
|
int maxDepth(struct TreeNode* root){
|
|
if (root == NULL)
|
|
return 0;
|
|
else
|
|
return 1 + maxval(maxDepth(root->left), maxDepth(root->right));
|
|
}
|
|
|