/**
 * struct TreeNode {
 *	int val;
 *	struct TreeNode *left;
 *	struct TreeNode *right;
 * };
 */
/**
 * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
 *
 * 
 * @param root TreeNode类 
 * @return int整型
 */
int maxDepthHelper(struct TreeNode* root, int d) {
    if(root == NULL) return d;
    int left = maxDepthHelper(root->left, d + 1);
    int right = maxDepthHelper(root->right, d + 1);
    if(left > right) {
        return left;
    }
    return right;
}

int maxDepth(struct TreeNode* root ) {
    // write code here
    int d = 0;
    return maxDepthHelper(root , d);
}