LeetCode104_MaximumDepthofBinaryTree Java题解
题目:
Given a binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
解题:
求最大深度 和前面一题类似 用递归遍历就能够
代码:
public static int maxDepth(TreeNode root) {
		if(root==null)//递归返回或结束条件
			return 0;
		else {
			return 1+Math.max(maxDepth(root.left),maxDepth(root.right) );
		}
    }
LeetCode104_MaximumDepthofBinaryTree Java题解的更多相关文章
- 【剑指offer】(第 2 版)Java 题解
		[剑指offer](第 2 版)Java 题解 第一章 面试的流程 略... 第二章 面试需要的基础知识 面试题 1. 赋值运算符函数 面试题 2. 实现 Singleton 模式 Solution ... 
- 试题 历届试题 核桃的数量 java题解
		资源限制 时间限制:1.0s 内存限制:256.0MB 问题描述 小张是软件项目经理,他带领3个开发组.工期紧,今天都在加班呢.为鼓舞士气,小张打算给每个组发一袋核桃(据传言能补脑).他的要求是: ... 
- TopCoder SRMS 1 字符串处理问题 Java题解
		Problem Statement Let's say you have a binary string such as the following: 011100011 One way to e ... 
- LeetCode108_Convert SortedArray to BinarySearchTree(将有序数组转成二叉排序树) Java题解
		题目: Given an array where elements are sorted in ascending order, convert it to a height balanced BST ... 
- 7.15实习培训日志 java题解
		周末总结 本周主要学习了markdown,git,docker等工具的使用.在本周的学习中,初步了解了markdown,git,docker的使用.本周的静态博客部署中,对于怎么显示一个博客内容,有两 ... 
- LeetCode234_PalindromeLinkedList (推断是否为回文链表)  Java题解
		题目: Given a singly linked list, determine if it is a palindrome. Follow up: Could you do it in O(n) ... 
- CF1256(div3 java题解)
		A: 题意:给定A个N元,B个一元,问是否可以凑成S元. 思路:A*i+j=S 即 A*I<=S<=A*I+B 即min(S/N,A)+B>=S: /* @author nimphy ... 
- L1-027 出租 (20 分) java题解
		下面是新浪微博上曾经很火的一张图: 一时间网上一片求救声,急问这个怎么破.其实这段代码很简单,index数组就是arr数组的下标,index[0]=2 对应 arr[2]=1,index[1]=0 对 ... 
- L1-023 输出GPLT (20 分) java题解 GPLT天梯赛防坑技巧
		上题目先 给定一个长度不超过10000的.仅由英文字母构成的字符串.请将字符重新调整顺序,按GPLTGPLT....这样的顺序输出,并忽略其它字符.当然,四种字符(不区分大小写)的个数不一定是一样多的 ... 
随机推荐
- nodejs-mysql模块
			安装mysql模块 1 npm install -g mysql node中使用Mysql模块来执行mysql命令 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 var ht ... 
- BA-siemens-symaro传感器简介
			1 传感器的原理 传感器.控制器.执行机构是构成控制系统 3 个要素,传感器的作 用一般用来测量工艺参数,提供给控制器或显示仪表,实现工艺过程的 监测或控制.传感器的类型是按测量参数不同分类的,主要分 ... 
- N - 畅通工程再续
			N - 畅通工程再续 思路:zz #include<cmath> #include<cstdio> #include<cstring> #include<io ... 
- Ubuntu16.04编译cmake源码
			编译版本:cmake-3.8.0-rc2 为了能够编译出ccmake和cmake-gui,首先需要安装libncurses5-dev sudo apt install libncurses5-dev ... 
- hdu 4037   Development Value(线段树维护数学公式)
			Development Value Time Limit: 5000/3000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others ... 
- Spork: Pig on Spark实现分析
			介绍 Spork是Pig on Spark的highly experimental版本号,依赖的版本号也比較久,如之前文章里所说.眼下我把Spork维护在自己的github上:flare-spork. ... 
- MFC exe使用C++ dll中的std::string 崩溃
			VC6中 MFC exe中 new 纯C++ dll dll 崩溃 我把纯C++的 dll,用/MTd 换成/MDd.就能够了 
- HTML iframe 和 frameset 的区别
			转自:http://www.cnblogs.com/polk6/archive/2013/05/24/3097430.html HTML iframe 和 frameset 的区别 iframe 和 ... 
- Redis学习笔记(八) 基本命令:SortedSet操作
			原文链接:http://doc.redisfans.com/sorted_set/index.html SortedSet的数据结构类似于Set,不同的是Sorted中的每个成员都分配了一个值(Sco ... 
- SQL*PLUS命令的使用大全
			Oracle的sql*plus是与oracle进行交互的客户端工具.在sql*plus中,可以运行sql*plus命令与sql*plus语句. 我们通常所说的DML.DDL.DCL语句都是sql*pl ... 
