71.二叉树的深度

https://www.cnblogs.com/king-lps/p/10748535.html

http://39.96.217.32/blog/4#comment-container

https://www.cnblogs.com/du001011/p/11229170.html

class Solution {
public:
    int treeDepth(TreeNode* root) {
        //1.终止条件:当树为空时结束递归,并返回当前深度0
        if(root == NULL){
            return 0;
        }
        //3.本级递归应该做什么.root的左、右子树的最大深度
        int leftDepth = treeDepth(root->left);
        int rightDepth = treeDepth(root->right);
        //2.找返回值。返回的是左右子树的最大深度+1
        return max(leftDepth, rightDepth) + 1;
        
    }
};

注意,表示节点为空

正确:if(root == NULL)
正确:if(!root )
错误:if(root == null)
带女朋友搬家新家条件不好,累到女朋友了,让女朋友受苦了,特此明志:每天学习,明年这个时候(20190812)让女朋友住上大房子,永远年轻,永远热泪盈眶,很多人都是这样,他们都把自己当成身在梦中一样,浑浑噩噩地过日子,只有痛苦或爱或危险可以让他们重新感到这个世界的真实。
原文地址:https://www.cnblogs.com/make-big-money/p/12337746.html