Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your alg...
分类:
其他好文 时间:
2014-09-06 13:39:03
阅读次数:
177
Given a singly linked listL: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 exam...
分类:
其他好文 时间:
2014-09-06 12:20:43
阅读次数:
223
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then le...
分类:
其他好文 时间:
2014-09-06 12:20:23
阅读次数:
171
Binary Tree Level Order Traversal II
Total Accepted: 16983 Total
Submissions: 54229My Submissions
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie...
分类:
其他好文 时间:
2014-09-05 18:22:41
阅读次数:
212
Binary Tree Level Order Traversal
Total Accepted: 20571 Total
Submissions: 66679My Submissions
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left t...
分类:
其他好文 时间:
2014-09-05 18:22:21
阅读次数:
271
Binary Tree Postorder Traversal
Total Accepted: 28560 Total
Submissions: 92333My Submissions
Given a binary tree, return the postorder traversal of its nodes' values.
For example:
Given...
分类:
其他好文 时间:
2014-09-05 16:09:01
阅读次数:
172
赋值语句
lua可以对多个变量同时赋值,变量列表,值列表的各个元素用逗号隔开。赋值语句右边会依次给左边的变量。
a, b = 10, 2*x a = 10; b=2*x;
lua会先计算右边所有的值,然后再执行赋值操作。
x, y = y, x -- swap x for y
当同时赋值遇到变量个数与值个数不一致时,
a. 变量个数 > 值的个数 不足的布n...
分类:
其他好文 时间:
2014-09-05 14:28:11
阅读次数:
141
Given a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a multiple ofkthen left-o...
分类:
其他好文 时间:
2014-09-05 12:53:01
阅读次数:
260
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2->3-...
分类:
其他好文 时间:
2014-09-05 05:31:40
阅读次数:
176
templatevoid swap(T* a, T* b){ T temp = *a; *a = *b; *b = temp;}//数组的全排列void perm(int list[], int k, int m){ if (k==m) { copy(list,list+m...
分类:
其他好文 时间:
2014-09-04 20:44:00
阅读次数:
235