前面写了一些关于树的操作,但是没有实现树的遍历的非递归写法。
通常树有四种遍历方法:1.层次遍历(需要用到树的高度,此文没有考虑)
2.前序遍历(根左右);3.中序遍历(左根右);4.后序遍历(左右根)
树的结构如下:
层次遍历:123456789
前序遍历:124895367
中序遍...
分类:
其他好文 时间:
2015-05-13 06:26:04
阅读次数:
125
public class Solution { public String convert(String s, int numRows) { String res = ""; if (s.length() < numRows || numRows == 1) { ...
分类:
其他好文 时间:
2015-05-13 06:17:07
阅读次数:
108
注意Integer.MIN_VALUE的绝对值是比Integer.MAX_VALUE大1的public class Solution { public int reverse(int x) { int res = 0; int num = Math.abs(x); ...
分类:
其他好文 时间:
2015-05-13 06:16:03
阅读次数:
94
作用:在侧栏中,显示头像 & 去掉文章最下边的广告!做法:自定义CSS,拦截广告模块;自定义HTML,将html代码添加上去,实现功能================(一)显示头像1、先获取到头像显示的html代码 点击自己de显示名,进入用户页面,如:2、进入“设置”界面 主页--> 管理(进.....
分类:
其他好文 时间:
2015-05-13 06:18:25
阅读次数:
241
Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephon...
分类:
其他好文 时间:
2015-05-13 06:17:42
阅读次数:
157
Destroy Tunnels原来早忘记了离散里含有这么一个叫传递闭包的东西矩阵A的闭包B = A U A^2 U A^3 U ...所以这里直接如果A[i][j]!= 0,建边i->j跑一遍强连通,看是不是只有一个强连通分量,>=2说明不能所有点都!=0输出exists否则说明所有i->j(i!=...
分类:
其他好文 时间:
2015-05-13 06:14:33
阅读次数:
224
Problem DescriptionThere are n houses in the village and some bidirectional roads connecting them. Every day peole always like to ask like this "How f...
分类:
其他好文 时间:
2015-05-13 06:11:50
阅读次数:
214
1、将 项目|项目属性|配置属性|连接器|清单文件|嵌入清单 “是”改为“否”。2、找到 C:\Windows\winsxs\x86_netfx-cvtres_for_vc_and_vb_b03f5f7f11d50a3a_6.1.7601.17514_none_ba1c770af0b2031b 目录...
分类:
其他好文 时间:
2015-05-13 06:14:25
阅读次数:
97
$path='E:/wamp/phplianxi/';$nested_list = readDirSNested($path, 0);echo '';var_dump($nested_list);/*** 递归读取目录内容* @param string $path 需要读取的目录内容* @retur...
分类:
其他好文 时间:
2015-05-13 06:13:15
阅读次数:
106
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3069题目大意:用最少警力,监控一个树,逮住逃犯。即最大警力去一个子树捉人时,确保父点至少被一个警察看守着。解题思路:对于一个结点,先树形dfs求出所有子树需要布置的最大警力maxSub捉人策略如下:边界...
分类:
其他好文 时间:
2015-05-13 06:10:10
阅读次数:
174
2015 UESTC Training for Search Algorithm & String
分类:
其他好文 时间:
2015-05-13 06:11:53
阅读次数:
153
1、安装依赖 sudo apt-get install libv4l-dev libjpeg8-dev imagemagick2、下载安装包 下载mjpg-streamer-code-182.zip,直接通过U盘复制到pcduino的“/home/ubuntu”目录下 http://pan.b...
分类:
其他好文 时间:
2015-05-13 06:09:49
阅读次数:
289
UIView的常见属性://获得自己的父控件对象@property(nonatomic,readonly) UIView *superview;//获得自己的所有子控件对象@property(nonatomic,readonly,copy) NSArray *subviews;//控件的ID\标识,...
分类:
其他好文 时间:
2015-05-13 06:09:56
阅读次数:
138
2015 UESTC Training for Search Algorithm & String
分类:
其他好文 时间:
2015-05-13 06:11:35
阅读次数:
179
2015 UESTC Training for Search Algorithm & String
分类:
其他好文 时间:
2015-05-13 06:08:25
阅读次数:
116
今天用自动布局纯代码的方式,并且引用第三方库写了一个微博界面的案例,其中的每个约束之间都是相互联系的,例如label 和 text 不能设置宽度和高度的具体数值,一旦固定下来,可能会出现错误,例如不会换行,文字显示不全等等一些列问题,一个技巧,手动布局时,最好从一侧开始进行约束,一般推荐上面和左侧,...
分类:
其他好文 时间:
2015-05-13 06:10:07
阅读次数:
222
2015 UESTC Training for Search Algorithm & String
分类:
其他好文 时间:
2015-05-13 06:07:42
阅读次数:
140