1. Binary Tree Maximum Node

Find the maximum node in a binary tree,return the node.

 public class MaximumNode{
public TreeNode maxNode(TreeNode root){
if(root == null) return root;
TreeNode left = maxNode(root.left);
TreeNode right = maxNode(root.right);
return max(root,max(left,right));
}
public TreeNode max(TreeNode node,TreeNode anotherNode){
if(node == null) return anotherNode;
if(anotherNode == null) return node;
if(node.val > anotherNode.val) return node;
return anotherNode;
}
}

Navie level questions的更多相关文章

  1. Layout Team

    The layout team is a long-term engineering team tasked with maintaining, supporting, and improving t ...

  2. [Node.js]33. Level 7: Persisting Questions

    Let's go back to our live-moderation app and add some persistence, first to the questions people ask ...

  3. WCF学习系列三--【WCF Interview Questions – Part 3 翻译系列】

    http://www.topwcftutorials.net/2012/10/wcf-faqs-part3.html WCF Interview Questions – Part 3 This WCF ...

  4. [转]Design Pattern Interview Questions - Part 4

    Bridge Pattern, Composite Pattern, Decorator Pattern, Facade Pattern, COR Pattern, Proxy Pattern, te ...

  5. [转]Design Pattern Interview Questions - Part 1

    Factory, Abstract factory, prototype pattern (B) What are design patterns? (A) Can you explain facto ...

  6. cassandra-replication_factor 和 consistency level

    参考 replication_factor 决定了数据会被写到多少个节点.为2表示要写到两个节点. consistency level决定客户端要等待多少个节点被写成功.为1表示只要第一个节点被写成功 ...

  7. investopedia level 2

    Mispricing can be explained by the sum of the two components: true mispricing and estimation errorVe ...

  8. How To Ask Questions The Smart Way

    How To Ask Questions The Smart Way Eric Steven Raymond Thyrsus Enterprises <esr@thyrsus.com> R ...

  9. 【Binary Tree Level Order Traversal】cpp

    题目: Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to ri ...

随机推荐

  1. 在BootStrap的modal中使用Select2搜索框无法输入

    用modal来show一个对话框 dialog.modal({ backdrop:true, keyboard:true, show:true }); 1 2 3 4 5 然后再modal中初始化se ...

  2. 解决strcmp的错误以及VS的快捷键

    主要是C++数组作业中发现的一些问题. 第一点是关于strcat函数 我用VS2018调用strcat的时候报错,错误信息提示strcat不安全(?)要用strcat_s.修改后,可成功运行. 但这两 ...

  3. 用python优雅打开文件及上下文管理协议

    有次面试被问到如何优雅地打开一个文件?   那就是用with语句,调用过后可以自动关闭.   但是为什么使用with语句就可以自动关闭呢,原因就是上下文管理协议.   上下文管理协议:包含方法 __e ...

  4. 微信小程序实现计算器功能

    page { height:100%;} .calculator { width: 100%; height: 100vh; border:solid 1px; background: rgb(238 ...

  5. SQL(ORACLE)

    查询数据库编码: select * from sys.nls_database_parameters;select * from sys.nls_session_parameters; replace ...

  6. 数据库中多对多关系的处理 User---Role

    --一个用户可以担任多个角色,如user1既是调度员又是分拣员--一个角色可以被多个用户担任,如user1是调度员,user2也是调度员--用户和角色之间的对应关系为多对多,所以会产生中间表 t_us ...

  7. ubuntu安装jdk,maven,tomcat

    ubuntu16.04安装jdk8 -jdk 检查是否安装成功 java -version 出现如上信息即安装成功 安装maven,先去官网下载指定版本的maven,个人使用apache-maven- ...

  8. cdnbest节点动态ip配置教程

    1.安装节点后,在未初始化里初始化节点,如下图操作,要选择动态ip(注:动态ip节点不支持添加辅ip) 服务器如果是动态ip,选择了动态ip选项,节点在自动更换了新的ip后,在节点列表里的ip和dns ...

  9. 九、Brideg 桥接模式

    设计原理: 代码清单: 抽象类 DisplayImpl public abstract class DisplayImpl { public abstract void rawOpen(); publ ...

  10. 判断JS的数据类型

    typeof.instanceof. constructor. prototype方法比较 (摘自如何判断JS中的数据类型) 1. 使用typeof操作符. 对一个值使用 typeof 操作符可能返回 ...