Bootstrap

力扣104 二叉树的最大深度

 This is the address of the question.

   104. 二叉树的最大深度

The key to this question is to find the height of the tree.
Let's show you the code for this question.

If you don't know what the height of the tree is, you can check out my previous blog post.

int maxDepth(struct TreeNode* root) {
	if (root == NULL)
		return 0;
	int leftHeight = maxDepth(root->left);
	int rightHeight = maxDepth(root->right);

	return	leftHeight > rightHeight ? leftHeight + 1 : rightHeight + 1;
}

;