static int i;
static TreeNode p;
static public TreeNode maxNode(TreeNode root) {
// write your code here
if(root==null)return null;
p=root;
i=root.val;
findmax(root);
return p;
}
static public void findmax(TreeNode root){
if(root!=null){
findmax(root.left);
findmax(root.right);
if(root.val>p.val&&root.val>i)
{
p=root;
i=root.val;
}
}
}
LintCode 二叉树的最大节点
最新推荐文章于 2019-06-17 09:41:57 发布