【leetcode】104. 二叉树的最大深度

题目链接 104. 二叉树的最大深度
【leetcode】104. 二叉树的最大深度_第1张图片

int maxDepth(struct TreeNode* root) {
    if (root == NULL) {
		return 0;
	}
	// 选出左子树和右子树中较高的树 + 根节点本身高度
	return fmax(maxDepth(root->left), maxDepth(root->right)) + 1;
}

你可能感兴趣的:(Data,Structure,and,Algorithm,C语言,刷题,leetcode,算法,数据结构,c语言)