摘要: Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], and [2,1,1]. DFS + 剪枝class Solution {public: void DFS(vector &num, int size,vector temp) { if(size == n){ ... 阅读全文
posted @ 2013-07-25 22:46 冰点猎手 阅读(298) 评论(0) 推荐(0)
摘要: 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] 找全排列,DFS的一般应用class Solution {public: void DFS(vector &num, int size,vector temp) { if(size == n){ resul... 阅读全文
posted @ 2013-07-25 20:56 冰点猎手 阅读(284) 评论(0) 推荐(0)
摘要: Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest substring is "b", with the length of 1.  阅读全文
posted @ 2013-07-25 20:42 冰点猎手 阅读(207) 评论(0) 推荐(0)
摘要: Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. 分析: DP 问题Initial state:table[i][i] = true.table[i][i+1] = (s[i]==s[i+1]);State Change:if s[i]==s[j],table[i][j]=table[i+1][.. 阅读全文
posted @ 2013-07-25 11:51 冰点猎手 阅读(179) 评论(0) 推荐(0)