二叉树最大深度 - lifengyu360/lifengyu_first_git_test GitHub Wiki

class Solution {

public:

int max_depth = 0;
int maxDepth(TreeNode* root) {
    if (root==NULL){
        return 0;
    }
    int left = maxDepth(root->left);
    int right = maxDepth(root->right);
    return (max(left,right) +1);
}

};