Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note...
分类:
其他好文 时间:
2014-07-02 22:49:05
阅读次数:
249
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.
分类:
其他好文 时间:
2014-07-02 10:01:21
阅读次数:
173
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first
two lists.
代码如下:
* Definition for singly-linked list.
* struct L...
分类:
其他好文 时间:
2014-07-02 07:23:59
阅读次数:
159
英语渣就是这点不好。。。
巨恶心这种描述多的题。。
大意就是求 从一个点出发,到某些点,然后又从那些点返回的距离之和的 最小值。
Dijkstra+邻接矩阵。 正向建图,求出出发距离,然后swap边,求出 返回距离。
注意的是 车可能有重复的。某个点有多少车就需要乘以车的数量。
#include
#include
#include
#include
#in...
分类:
其他好文 时间:
2014-07-02 07:16:49
阅读次数:
253
题目:Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,...
分类:
其他好文 时间:
2014-07-01 12:44:09
阅读次数:
199
题目:Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For ...
分类:
其他好文 时间:
2014-07-01 12:26:07
阅读次数:
215
题目
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 digit. Add the two numbers and return it a...
分类:
其他好文 时间:
2014-07-01 09:11:07
阅读次数:
206
题目
Given a singly linked list L: L0→L1→…→Ln-1→Ln,
reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…
You must do this in-place without altering the nodes' values.
For example,
Given {1,2,3,4}, re...
分类:
其他好文 时间:
2014-07-01 08:39:24
阅读次数:
181
题目
Given a binary tree, return the preorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [1,2,3].
Note: Recu...
分类:
其他好文 时间:
2014-07-01 07:06:56
阅读次数:
177
题目
Given a binary tree, return the postorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [3,2,1].
Note: Rec...
分类:
其他好文 时间:
2014-07-01 07:06:11
阅读次数:
214