Lowest Common Ancestor of a Binary Tree Total Accepted: 6162 Total Submissions: 23311 My Submissions Question Solution
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in...
分类:
其他好文 时间:
2015-07-26 19:23:17
阅读次数:
192
Kth Smallest Element in a BST
Given a binary search tree, write a function kthSmallestto find the kth
smallest element in it.
Note:
You may assume k is always valid, 1 ≤ k ≤ BST's total elem...
分类:
其他好文 时间:
2015-07-26 15:52:22
阅读次数:
125
Given a binary tree containing digits from 0-9 only, each root-to-leaf path
could represent a number.
An example is the root-to-leaf path 1->2->3 which represents the number 123.
Find the tota...
分类:
其他好文 时间:
2015-07-26 15:50:28
阅读次数:
113
Redis_DataType.htmlRedis-DataTypeRedis是一个键值对型的数据库,但是支持多种数据结构。具体如下:Binary-safe strings 意义为在进行对二进制的解码和编码时,不具有特殊字符,如转义字符,char数组中的\0,结尾加null等都不是二进制安全的。关键在...
分类:
其他好文 时间:
2015-07-26 15:31:49
阅读次数:
211
主要是如何实现在某些层的翻转,使用两个队列。记录两个层。如果需要翻转,则翻转。这里实际上有一个翻转的消耗。可以使用双端队列,在插入时就是正确的顺序,无需翻转。 1 2 3456 7level 1: 1level 2: 3 2level 3: 7 6 5 4使用flag控制读写方向即可,这样放到lis...
分类:
其他好文 时间:
2015-07-26 12:29:41
阅读次数:
115
两种思路一、level by level使用两个queue,queue1记录当前访问的层,queue2记录下一个层,最后queue1清空,queue2拷贝至queue1.二、depth first traval使用参数传递level,在适当的时刻增加层数[1]http://www.cnblogs.c...
分类:
其他好文 时间:
2015-07-26 12:27:51
阅读次数:
145
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.
According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes ...
分类:
其他好文 时间:
2015-07-26 11:11:32
阅读次数:
136
SRM 661-Medium: BridgeBuildingDiv2
Problem Statement
You have two rows of nodes. Each row contains N nodes, numbered 0 through N-1 from the left to the right.
Within each row, adjacent nodes...
分类:
其他好文 时间:
2015-07-26 00:35:52
阅读次数:
290
Amr lives in Lala Land. Lala Land is a very beautiful country that is located on a coordinate line. Lala Land is famous with its apple trees growing e...
分类:
移动开发 时间:
2015-07-26 00:26:11
阅读次数:
245
最近由于工作的需要,要在centos上安装MYSQL服务器。作为一名小兵中的小兵,当然是没有root权限的,为了能够使用mysql,只能使用源码安装了(因为binary安装方式似乎需要root access的)一、Mysql下载mysql.5.6.24二、解压tar zxvf mysql.tar.g...
分类:
数据库 时间:
2015-07-25 21:25:28
阅读次数:
177