摘要: Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]思路:本题就是一个组合问题,举个例子就会明白了。例如n=4,k=2,则先将1放入一数组中,然后step记为1,然后循环遍历2加入数组,step记为2,依次加入,等step==k时停止,最后将这个数组加入到vector >中。如果没到达4,则pop最后... 阅读全文
posted @ 2014-04-02 16:15 Awy 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 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 the second node from the end, the linked list becomes 1->2->3->5.Note:Givennwill always be valid.Try to do this in one pass.思路 阅读全文
posted @ 2014-04-02 15:27 Awy 阅读(272) 评论(0) 推荐(0) 编辑