/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
int max=0;
int val=0;
int maxDepth(TreeNode* root) {
if(root!=nullptr){
val=val+1;
root->val=val;
if(max<val){max=val;}
maxDepth(root->left);
maxDepth(root->right);
val--;
}
return max;
}
};