摘要: 1 int dp[1000000]; 2 class Solution { 3 public: 4 int rob(vector& nums) { 5 int i,n=nums.size(); 6 if(n==0) 7 return ... 阅读全文
posted @ 2015-06-09 22:12 varcom 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 bool isHappy(int n) { 4 int dig[1000],cnt,ans; 5 memset(dig,0,sizeof(dig)); 6 while(1) 7 ... 阅读全文
posted @ 2015-06-09 20:05 varcom 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 ListNode* removeElements(ListNode* head, int val) { 4 ListNode*cur,*nxt,*pre=head; 5 if(head==NULL... 阅读全文
posted @ 2015-06-09 19:27 varcom 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 1 int ary[1500005]; 2 class Solution { 3 public: 4 int countPrimes(int n) { 5 int i,j; 6 memset(ary,0,sizeof(ary)); 7 int... 阅读全文
posted @ 2015-06-09 11:20 varcom 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 bool isIsomorphic(string s, string t) { 4 map mp; 5 int sl=s.size(),st=t.size(); 6 if(sl!=... 阅读全文
posted @ 2015-06-08 10:16 varcom 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 ListNode* reverseList(ListNode* head) { 4 if(head==NULL) 5 return head; 6 ListNode* pr... 阅读全文
posted @ 2015-06-07 20:48 varcom 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 bool containsDuplicate(vector& nums) { 4 int n=nums.size(); 5 if(n==0) 6 return 0; 7 ... 阅读全文
posted @ 2015-06-07 10:13 varcom 阅读(95) 评论(0) 推荐(0) 编辑
摘要: 1 struct Rec 2 { 3 int dig, ind; 4 }; 5 bool cmp(struct Rec a,struct Rec b) 6 { 7 if(a.dig!=b.dig) 8 return a.dig& nums, int k) {14 ... 阅读全文
posted @ 2015-06-06 18:37 varcom 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 string longestCommonPrefix(vector& strs) { 4 if(strs.empty()) 5 return ""; 6 vector::i... 阅读全文
posted @ 2015-06-06 17:27 varcom 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 int romanToInt(string s) { 4 int i,len=s.size(); 5 int dig[20]; 6 for(i=0;i<len;i++) 7 ... 阅读全文
posted @ 2015-06-06 11:38 varcom 阅读(114) 评论(0) 推荐(0) 编辑