[leetcode]Permutations

摘要: PermutationsGiven 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]... 阅读全文
posted @ 2014-07-22 16:26 喵星人与汪星人 阅读(209) 评论(0) 推荐(0) 编辑

[leetcode]Combinations

摘要: CombinationsGiven two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3... 阅读全文
posted @ 2014-07-22 15:40 喵星人与汪星人 阅读(277) 评论(0) 推荐(0) 编辑

[leetcode]Triangle

摘要: TriangleGiven a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given... 阅读全文
posted @ 2014-07-22 01:41 喵星人与汪星人 阅读(308) 评论(0) 推荐(0) 编辑

[leetcode]Pascal's Triangle II

摘要: Pascal's Triangle IIGiven an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your alg... 阅读全文
posted @ 2014-07-22 01:01 喵星人与汪星人 阅读(253) 评论(0) 推荐(0) 编辑

[leetcode]Pascal's Triangle

摘要: Pascal's TriangleGivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,... 阅读全文
posted @ 2014-07-22 00:35 喵星人与汪星人 阅读(413) 评论(0) 推荐(0) 编辑

[leetcode]Remove Duplicates from Sorted Array II

摘要: Remove Duplicates from Sorted Array IIFollow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted array A =... 阅读全文
posted @ 2014-07-21 23:55 喵星人与汪星人 阅读(242) 评论(0) 推荐(0) 编辑

[leetcode]Remove Duplicates from Sorted Array

摘要: Remove Duplicates from Sorted ArrayGiven a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new lengt... 阅读全文
posted @ 2014-07-21 23:35 喵星人与汪星人 阅读(262) 评论(0) 推荐(0) 编辑

[leetcode]Remove Element

摘要: Remove ElementGiven an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. ... 阅读全文
posted @ 2014-07-21 23:11 喵星人与汪星人 阅读(169) 评论(0) 推荐(0) 编辑

[leetcode]Sort List

摘要: Sort ListSort a linked list inO(nlogn) time using constant space complexity.算法思想:时间复杂度为O(nlogn)的排序算法,有快排、归并、堆排序,快排需要往前遍历,因此不适合单链表,堆排序可以,但是需要O(n)的空间,因此... 阅读全文
posted @ 2014-07-21 22:33 喵星人与汪星人 阅读(258) 评论(0) 推荐(0) 编辑

[leetcode]Reverse Linked List II

摘要: Reverse Linked List IIReverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return... 阅读全文
posted @ 2014-07-21 21:19 喵星人与汪星人 阅读(183) 评论(0) 推荐(0) 编辑