int result = 0;
public int MaxDepth(TreeNode root)
{
if (root == null) return 0;
result = Math.Max(MaxDepth(root.left), MaxDepth(root.right)) + 1;
return result;
}
c# 解答了此题
还是用到递归算法
虽然做了出来,但在工作中还没有遇到用Tree解决的问题,如果谁有这方面的项目疑问需要用到tree 来解决的话,欢迎留言告诉我。