static int _depth = 1;
class Solution {
public:
int maxDepth(TreeNode *root) {
if (!root)
return 0;
DepthTravle(root, 1);
return _depth;
}
void DepthTravle(TreeNode *node, int depths){
if (_depth <= depths)
{
_depth = depths;
}
if (node>left) DepthTravle(node>left, depths + 1);
if (node>right) DepthTravle(node>right, depths + 1);
}
};
Input: {0,0,0,0,#,#,0,#,#,#,0}
Output: 5
Expected: 4
but i test in my IDE is output 4
{0,0,0,0,#,#,0,#,#,#,0}
is that ?
0
 
0 0
 
0 0

0