思路:类似于上一题,但是加了一个index数组记录结果里面已经存放的元素索引,用来判断当前的元素是否和上一个相同并且上一个是否使用过。主要为了解决重复解的问题。 1 class Solution { 2 public: 3 vector >ans; 4 vector > combin...
分类:
其他好文 时间:
2014-08-03 23:01:56
阅读次数:
213
题目: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,....
分类:
编程语言 时间:
2014-08-03 10:09:25
阅读次数:
193
Corner cases!class Solution {public: ListNode *deleteDuplicates(ListNode *head) { if (!head) return head; if (!head->next) return hea...
分类:
其他好文 时间:
2014-08-03 07:51:34
阅读次数:
237
题目:Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].Note:Could you optimize your algorithm to ....
分类:
编程语言 时间:
2014-08-03 05:24:06
阅读次数:
304
题目: Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the foll....
分类:
编程语言 时间:
2014-08-03 05:21:18
阅读次数:
272
Problem Description
The doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze was changed and the way he came in was lost.He realized that the bo...
分类:
其他好文 时间:
2014-08-02 23:31:54
阅读次数:
274
Single Number II
Given an array of integers, every element appears three times except for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?...
分类:
其他好文 时间:
2014-08-02 12:53:53
阅读次数:
289
题目:Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty spa....
分类:
编程语言 时间:
2014-08-02 12:19:13
阅读次数:
241
Lexicographicallyalgorithms:1. Iterate array from back to front, and find the first decreasing point: 1,2,4,3 -- 42. Iterate array from back to front,...
分类:
其他好文 时间:
2014-08-02 05:11:02
阅读次数:
199
题目:Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each ....
分类:
编程语言 时间:
2014-08-02 01:48:12
阅读次数:
246