Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3].二叉树...
分类:
其他好文 时间:
2014-11-16 13:23:07
阅读次数:
138
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(())()", "()(())", "()()()"思路分析:...
分类:
其他好文 时间:
2014-11-16 10:44:42
阅读次数:
164
Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the origi...
分类:
其他好文 时间:
2014-11-16 09:24:55
阅读次数:
216
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the o...
分类:
其他好文 时间:
2014-11-16 08:15:41
阅读次数:
222
same question as:why is PAXOS necessary?1, what if >1 nodes become leaders simultaneously?that's why we need phase#1 (prepare) to select a leader.2, w...
分类:
其他好文 时间:
2014-11-16 08:15:30
阅读次数:
210
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example,Given 1->2...
分类:
其他好文 时间:
2014-11-16 08:14:02
阅读次数:
220
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single ...
分类:
其他好文 时间:
2014-11-15 21:41:07
阅读次数:
315
前几天突然看到一段代码,虽然很简单,但引起了我的一些感慨…… 1 #include 2 3 int main() 4 { 5 int a, b; 6 scanf("%d %d", &a, &b); 7 Swap(a, b); 8 ...
分类:
其他好文 时间:
2014-11-15 21:33:35
阅读次数:
142
可能是因为我是按难度顺序刷的原因,这个其实在之前的几道题里面已经写过了。题目如下: Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path...
分类:
其他好文 时间:
2014-11-15 21:31:17
阅读次数:
194
跟第七题一样,把最后的输出顺序换一下就行。。。 Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For exam...
分类:
其他好文 时间:
2014-11-15 21:29:30
阅读次数:
231