Skip to content

Commit

Permalink
Remove Unnecessary function in problem #104.c
Browse files Browse the repository at this point in the history
  • Loading branch information
swayam9705 authored Dec 19, 2024
1 parent e5dad3f commit da10178
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions leetcode/src/104.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@
* };
*/

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));
else {
// return 1 + maxval(maxDepth(root->left), maxDepth(root->right));
int leftDepth = maxDepth(root -> left);
int rightDepth = maxDepth(root -> right);

return leftDepth > rightDepth ? 1 + leftDepth : 1 + rightDepth;
}
}

0 comments on commit da10178

Please sign in to comment.