TheAlgorithms-C/leetcode/src/104.c
2019-09-03 08:52:24 -07:00

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));
}