摘要: Given a collection of numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1]. 1 public static List<List<int>> Permutation(List<int> num) 2 { 3 List<List<int>> ret = new List& 阅读全文
posted @ 2012-10-05 22:11 ETCOW 阅读(573) 评论(0) 推荐(0) 编辑
摘要: The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3):"123""132""213""231""312""321"Given n and k, return the kth permutation se 阅读全文
posted @ 2012-10-05 04:39 ETCOW 阅读(262) 评论(0) 推荐(0) 编辑
摘要: 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 nodes in each of the two partitions.For example,Given 1->4->3->2->5->2 and x = 3,return 1->2->2-> 阅读全文
posted @ 2012-10-05 04:08 ETCOW 阅读(431) 评论(0) 推荐(0) 编辑