Two elements of a binary search tree (BST) are
swapped by mistake.Recover the tree without changing its structure.Note:A
solution using O(n) space is ...
分类:
其他好文 时间:
2014-05-17 11:30:21
阅读次数:
247
题目:Givennpoints on a 2D plane, find the maximum
number of points that lie on the same straight
line.算法分析:定义最大直线为符合相同条件的直线中通过点最多的那条直线。对每个点p,计算其它的点与p形成的...
分类:
其他好文 时间:
2014-05-16 23:26:31
阅读次数:
389
Given a string S, find the longest palindromic
substring in S. You may assume that the maximum length of S is 1000, and there
exists one unique longes...
分类:
其他好文 时间:
2014-05-16 21:15:37
阅读次数:
454
题目: Givennpoints on a 2D plane, find the maximum
number of points that lie on the same straight line.解题思路:
第一反应:枚举两个点组成的直线,然后看其他的点在不在这条直线上,在此过程中统计最大.....
分类:
其他好文 时间:
2014-05-16 05:54:57
阅读次数:
193
5道题目分别是:【Interleaving String】、【Validate Binary Search Tree】、【Sqrt(x) 】、【Recover Binary Search Tree 】、【Climbing Stairs 】,由于有一些题目不需要发一整篇博文来记录,所以就将这些题目以一篇博文5道来记录。...
分类:
其他好文 时间:
2014-05-15 06:30:55
阅读次数:
301
题意:给定一棵任意二叉树(不一定是perfect binary tree),将它每一个节点的next指针都指向该节点右边的节点
思路:bfs
这里不能用dfs了,只能用bfs
bfs遍历将同一层的节点存放在同一个数组里,
然后在遍历每个数组,将前面的节点和后面的节点connect起来,
最后一个节点和NULL connect起来
需要定义一个新的struct结构,保存指向每个节点的指针和该节点所在的层
复杂度:时间O(n), 空间O( n)...
分类:
其他好文 时间:
2014-05-15 06:12:13
阅读次数:
294
Pat1043代码
题目描述:
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:
The left subtree of a node contains only nodes with keys less than t...
分类:
其他好文 时间:
2014-05-15 05:09:59
阅读次数:
351
tree --help以树型结构显示文件及文件夹usage: tree
[-acdfghilnpqrstuvxACDFQNSUX] [-H baseHREF] [-T title ] [-L level [-R]][-P
pattern] [-I pattern] [-o filename] [--...
分类:
系统相关 时间:
2014-05-14 11:15:56
阅读次数:
506
Extjs树形控件由Ext.tree.TreePanel类定义,控件的名称为TreePanel,TreePanel继承自Panel类,在Extjs中使用树形控件其实很简单.大家知道要使用Extjs必须引入他的库,所以我们要引入以下几个文件:ext-all.cssext-base.jsext-all....
分类:
Web程序 时间:
2014-05-14 10:52:18
阅读次数:
339
<!doctypehtml>
<html>
<metacharset="utf-8"/>
<head>
<title>益司CMS-PC与手机建站集成</title>
<metaname="viewport"content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
<linkrel="stylesh..
分类:
其他好文 时间:
2014-05-13 11:58:21
阅读次数:
335