/** * Definition for a binary tree node.
* public class TreeNode {
* * public int val;
* * public TreeNode left;
* * public TreeNode right;
* * public TreeNode(int x) { val = x; }
* * }
public class Solution {
public int MaxDepth(TreeNode root) {
if(root==null)
return 0;
else{
int m=MaxDepth(root.left);
int n=MaxDepth(root.right);
return Math.Max(m,n)+1;
}
}
}
二叉树的最大深度
最新推荐文章于 2023-06-07 00:20:51 发布