摘要: 解法一:Brute-force 1 int strStr(string haystack, string needle) 2 { 3 int m = haystack.size(); 4 int n = needle.size(); 5 if (!n) 6 ... 阅读全文
posted @ 2015-07-06 16:04 QingLiXueShi 阅读(504) 评论(0) 推荐(0) 编辑
摘要: 1 void merge(vector& nums1, int m, vector& nums2, int n) 2 { 3 int i = m - 1; 4 int j = n - 1; 5 int k = m + n - 1; 6 while (i >=0 &&... 阅读全文
posted @ 2015-07-06 14:57 QingLiXueShi 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 1 vector summaryRanges(vector& nums) 2 { 3 int nums_len = nums.size(); 4 vector res; 5 if (nums_len == 0) 6 return res; 7 8 ... 阅读全文
posted @ 2015-07-06 14:19 QingLiXueShi 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 1 bool isPowerOfTwo(int n)2 {3 return n > 0 && !(n & (n - 1));4 } 阅读全文
posted @ 2015-07-06 11:07 QingLiXueShi 阅读(171) 评论(0) 推荐(0) 编辑