Skip to content

Commit

Permalink
Time: 9 ms (24.79%), Space: 19.3 MB (6.11%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
Dipendra-Raghav committed Oct 2, 2023
1 parent f403937 commit 70f20c3
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
* TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
* };
*/
class Solution {
public:
int mx;
int solve(TreeNode *root)
{
if(root==NULL)return 0;
return 1+max(solve(root->left),solve(root->right));

}
int maxDepth(TreeNode* root) {
return solve(root);
}
};

0 comments on commit 70f20c3

Please sign in to comment.