摘要:
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]... 阅读全文
摘要:
CombinationsGiven two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3... 阅读全文
摘要:
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... 阅读全文
摘要:
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... 阅读全文
摘要:
Remove Duplicates from Sorted Array IIFollow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted array A =... 阅读全文
摘要:
Remove Duplicates from Sorted ArrayGiven a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new lengt... 阅读全文
摘要:
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. ... 阅读全文
摘要:
Sort ListSort a linked list inO(nlogn) time using constant space complexity.算法思想:时间复杂度为O(nlogn)的排序算法,有快排、归并、堆排序,快排需要往前遍历,因此不适合单链表,堆排序可以,但是需要O(n)的空间,因此... 阅读全文
摘要:
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... 阅读全文