Given a binary tree
struct TreeLinkNode {
TreeLinkNode *left;
TreeLinkNode *right;
TreeLinkNode *next;
}
Populate each next pointer to point to its next right node....
分类:
其他好文 时间:
2015-03-30 11:18:59
阅读次数:
108
Path Sum IIGiven 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 tr...
分类:
其他好文 时间:
2015-03-30 10:52:04
阅读次数:
158
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened t...
分类:
其他好文 时间:
2015-03-30 10:52:04
阅读次数:
106
Given a binary tree
struct TreeLinkNode {
TreeLinkNode *left;
TreeLinkNode *right;
TreeLinkNode *next;
}
Populate each next pointer to point to its next right node. ...
分类:
其他好文 时间:
2015-03-30 09:38:00
阅读次数:
163
题目:
Given n, how many structurally unique BST's (binary search trees) that store values 1...n?
For example,
Given n = 3, there are a total of 5 unique BST's.
1 3 3 2 ...
分类:
其他好文 时间:
2015-03-29 15:11:19
阅读次数:
106
思路:
首先中序遍历二叉查找树并将遍历的节点存储到一个list中,然后对list中的值进行比较,查找出位置出现变化的两个结点,将两个结点的值进行互换,完成本题的要求。
但是呢,对于如何发现位置出现变化的两个结点是本题的重点和难点,具体判断条件可以参见下面的程序,最后对查到的结点进行取舍也是一大问题,一般符合判断条件的结点会出现三个,我取的是第一个和第三个,这不好讲清楚,具体可自行推敲。...
分类:
其他好文 时间:
2015-03-29 12:20:09
阅读次数:
148
Flatten Binary Tree to Linked List问题:Given a binary tree, flatten it to a linked list in-place.思路: 前序pre-order遍历+prenode我的代码:public class Solution { ....
分类:
其他好文 时间:
2015-03-29 12:05:49
阅读次数:
104
1 // random.cpp -- random access to a binary file 2 #include // not required by most systems 3 #include 4 #include 5 #include // (o...
分类:
编程语言 时间:
2015-03-29 09:24:23
阅读次数:
159
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
{CSDN:CODE:630443}...
分类:
其他好文 时间:
2015-03-29 07:08:21
阅读次数:
128