(lintcode)第632题二叉树的最大节点
来源:互联网 发布:现货交易软件哪个好 编辑:程序博客网 时间:2024/06/05 09:05
要求:在二叉树中寻找值最大的节点并返回。
样例
给出如下一棵二叉树:
1 / \ -5 2 / \ / \0 3 -4 -5
返回值为 3
的节点,返回值是节点,不是数值。代码如下:
public class Solution { /** * @param root the root of binary tree * @return the max ndoe */ public TreeNode treenode=new TreeNode(-1000000000); public TreeNode maxNode(TreeNode root) { // Write your code here if(root==null) return null; else{ if(root.val>treenode.val) treenode=root; maxNode(root.left); maxNode(root.right); } return treenode; }}
阅读全文
0 0
- (lintcode)第632题二叉树的最大节点
- LintCode 第632题 二叉树的最大节点
- lintcode(632)二叉树的最大节点
- LintCode:二叉树的最大节点632
- LintCode-(632)二叉树的最大节点
- LintCode 二叉树的最大节点
- LintCode-二叉树的最大节点
- lintcode 二叉树的最大节点
- 二叉树的最大节点-LintCode
- [Lintcode]二叉树的最大节点
- lintcode--二叉树的最大节点
- LintCode二叉树的最大节点
- LintCode 二叉树的最大节点
- 二叉树的最大节点-LintCode
- LintCode 二叉树的最大节点
- Lintcode:二叉树的最大节点
- LintCode之632 二叉树最大节点
- 【LintCode-632】二叉树的最大节点(Java实现)
- git pull和git fetch的区别小结
- AndroidManifest权限配置
- Spring容器中Bean的作用域
- 超酷!可以缩小放大的 Viewpager
- android目录初识
- (lintcode)第632题二叉树的最大节点
- MVC、POJO、PO、DTO、TO、BO、VO、DAO、domian、delegate、sql
- test
- Linux相关知识
- Current transfer ratio电流传输系数
- hdu2609-字符串最小表示法|模拟|二分+lcp-How many
- TFboys:使用Tensorflow搭建深层网络分类器
- Azkaban学习笔记 --- Azkaban调研笔记后续
- 所有CSS伪类/元素