Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algor...
分类:
其他好文 时间:
2015-04-24 12:00:35
阅读次数:
98
Given a string S, find the length of the longest substring T that contains at most two distinct characters.Given S = “eceba”,T is “ece” which its leng...
分类:
其他好文 时间:
2015-04-24 07:48:35
阅读次数:
109
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...
分类:
其他好文 时间:
2015-04-23 23:19:15
阅读次数:
147
Reverse Nodes in k-Group
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 left-out nodes in ...
分类:
其他好文 时间:
2015-04-23 17:25:47
阅读次数:
124
Given a linked list, remove thenthnode from the end of list and return its head.For example.Given linked list: 1->2->3->4->5, and n = 2.After removing...
分类:
其他好文 时间:
2015-04-23 17:17:07
阅读次数:
97
Swap Nodes in Pairs
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 algorithm should u...
分类:
其他好文 时间:
2015-04-23 15:52:23
阅读次数:
186
Given a m x n matrix,
if an element is 0, set its entire row and column to 0. Do it in place.
遍历矩阵,如果遇到等于0的元素,则把该元素所在行的第一个元素和所在列第一个元素置为0。考虑到row0和col0会重合,所以另外设置一个变量col0来表示第一列的情况。
然后从左下角开始,把符合条件的元素置...
分类:
其他好文 时间:
2015-04-23 13:17:37
阅读次数:
104
problem:
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).
For example:
Given binary tree...
分类:
其他好文 时间:
2015-04-23 11:02:24
阅读次数:
163
定义:将一个复杂对象的构造与它的表示分离,使同样的构建过程可以创建不同的表示,这样的设计模式被称为建造者模式。
(separate the construction of a complex object from its representation so that the same construction process can create different representation...
分类:
其他好文 时间:
2015-04-23 00:02:43
阅读次数:
165
Given a binary tree, return the inorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [1,3,2].
Note: Recursive solutio...
分类:
其他好文 时间:
2015-04-22 20:38:31
阅读次数:
133