Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.用空间换时间的方法,先用一个数组将节点按序存放,然后建树,代码如下:/** * D...
分类:
其他好文 时间:
2015-04-10 21:51:05
阅读次数:
117
Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution stil...
分类:
其他好文 时间:
2015-04-10 19:33:42
阅读次数:
102
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointe...
分类:
其他好文 时间:
2015-04-10 17:25:22
阅读次数:
110
Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3].Not...
分类:
其他好文 时间:
2015-04-10 16:56:27
阅读次数:
117
去年google code jam第一轮的B题,我没有想明白,也没有找到题解。没有办法,就去下载了大神的代码来看看。感觉差距好大,别人用十分钟不到就做出来了。题目的描述如下,我就不写翻译了,题意挺明了的。由于墙的原因,我还是把题目贴下面吧!题目内容
A tree is a connected graph with no cycles.A rooted tree is a tree in which...
分类:
其他好文 时间:
2015-04-10 15:39:41
阅读次数:
218
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree andsum =...
分类:
其他好文 时间:
2015-04-10 15:14:35
阅读次数:
125
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Fo...
分类:
其他好文 时间:
2015-04-10 12:56:54
阅读次数:
109
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST....
分类:
编程语言 时间:
2015-04-10 09:32:42
阅读次数:
181
题目:Given a binary tree, imagine yourself standing on therightside of it, return the values of the nodes you can see ordered from top to bottom.For exa...
分类:
其他好文 时间:
2015-04-10 06:32:46
阅读次数:
104
Given a binary tree, determine if it is a valid binary search tree (BST).
Assume a BST is defined as follows:
The left subtree of a node contains only nodes with keys less than the...
分类:
其他好文 时间:
2015-04-09 23:54:16
阅读次数:
304