/**
* 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:
vector<int> p;
int res = 0;
int treeDepth(TreeNode* root) {
dfs(0, root);
return res;
}
void dfs(int u, TreeNode* root)
{
if(!root)
{
res = max(res, u);
return;
}
dfs(u + 1, root->left);
dfs(u + 1, root->right);
}
};