题目
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 original relative order of the node...
分类:
其他好文 时间:
2014-06-11 06:28:41
阅读次数:
364
题目
Reverse a linked list from position m to n. Do it in-place and in one-pass.
For example:
Given 1->2->3->4->5->NULL, m = 2 and n =
4,
return 1->4->3->2->5->NULL.
Note:
Given m,...
分类:
其他好文 时间:
2014-06-11 06:07:11
阅读次数:
392
题目
Given a sorted linked list, delete all duplicates such that each element appear only once.
For example,
Given 1->1->2, return 1->2.
Given 1->1->2->3->3, return 1->2->3.
方法
遍...
分类:
其他好文 时间:
2014-06-11 00:41:44
阅读次数:
207
几个实例展示python中数据结构list的魅力!
list变量申明
the_count = [1, 2, 3, 4, 5]
fruits = ['apples', 'oranges', 'pears', 'apricots']
change = [1, 'pennies', 2, 'dimes', 3, 'quarters']
访问list元素
array= [1,2,5,3,6,8...
分类:
编程语言 时间:
2014-06-11 00:16:28
阅读次数:
285
下面是python中字典的一种实现,用list数据结构实现字典。具体是这样的:[[(key1,value1),(key2,value2),...],[],[],...]
内部每一个hash地址是一个list,存放hash地址相同的(key,value)对。
dict代码
def Map(num_buckets=256):
"""Initializes a Map with t...
分类:
编程语言 时间:
2014-06-10 15:30:49
阅读次数:
298
ArrayList继承了List,
ArrayList没有继承List
List等价于List...
分类:
编程语言 时间:
2014-06-10 14:20:51
阅读次数:
262
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.水题不解释,一A,...
分类:
其他好文 时间:
2014-06-10 08:58:37
阅读次数:
191
分析:
问题是将给定的二叉树变换成令一种形式,这种类型的问题,其模式是,将左子树变换成某种形式,右子树也变换成这种形式,然后再与根结点按规定的方式连接起来,那么整体就变换完成了。这个题我们就可以采用这种形式,麻烦的地方就是在进行连接的时候,我们假设根为root,左子树变换后的根为root_left,右子树变换后的根为 root_right,那么连接的时候应该是root->right = root...
分类:
其他好文 时间:
2014-06-10 07:27:10
阅读次数:
201
Sort a linked list inO(nlogn) time using
constant space complexity.单向链表排序O(nlogn),Mergesort可以实现。 1 /** 2 * Definition for
singly-linked list. 3 * st.....
分类:
其他好文 时间:
2014-06-10 00:44:11
阅读次数:
329
package 线程安全测试;import java.util.ArrayList;import
java.util.List;import java.util.concurrent.ExecutorService;import
java.util.concurrent.Executors; cla...
分类:
编程语言 时间:
2014-06-10 00:41:04
阅读次数:
432