上一页 1 ··· 23 24 25 26 27 28 29 30 31 ··· 36 下一页
摘要: 1 class Solution { 2 public: 3 bool isP(string s) { 4 int start = 0, end = s.size()-1; 5 while (start > &result, vector current,... 阅读全文
posted @ 2015-03-21 16:36 keepshuatishuati 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 1. x/rec >= 10.2. find start and end of a number. 1 class Solution { 2 public: 3 bool isPalindrome(int x) { 4 if (x = 10) rec *= 10; 7 ... 阅读全文
posted @ 2015-03-21 15:22 keepshuatishuati 阅读(127) 评论(0) 推荐(0) 编辑
摘要: Scanning from start to end. If find a mismatch and one is larger size, keep search from the previous char of shorter one.Finally check whether found a... 阅读全文
posted @ 2015-03-21 15:17 keepshuatishuati 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 int hammingWeight(uint32_t n) { 4 int result = 0; 5 while (n > 0) { 6 if (n & 1) { 7 ... 阅读全文
posted @ 2015-03-21 10:04 keepshuatishuati 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 void swap(int &a, int &b){int t = a; a = b; b = t;}; 4 void reverse(vector &num, int start, int end) { 5 ... 阅读全文
posted @ 2015-03-21 09:49 keepshuatishuati 阅读(117) 评论(0) 推荐(0) 编辑
摘要: You can use N-Queens I 's method counting for the result. But it wont pass the leetcode test.Use bit operation will be much faster: 1 class Solution {... 阅读全文
posted @ 2015-03-21 09:39 keepshuatishuati 阅读(126) 评论(0) 推荐(0) 编辑
摘要: Brute Force: 1 class Solution { 2 public: 3 bool notExist(vector rec, int level, int current) { 4 for (int i = 0; i rec, vector &result) ... 阅读全文
posted @ 2015-03-21 09:24 keepshuatishuati 阅读(114) 评论(0) 推荐(0) 编辑
摘要: Notes:1. Dont have to allocate l1*l2, just l1+l2 is fare enough.2. remember i--, j--.3. upgrade[i+j] is += not = rec[i+j+1]/10; 1 class Solution { 2 p... 阅读全文
posted @ 2015-03-21 09:13 keepshuatishuati 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 string getRange(int start, int end) { 4 ostringstream oss; 5 if (start == end) { 6 oss... 阅读全文
posted @ 2015-03-21 08:13 keepshuatishuati 阅读(112) 评论(0) 推荐(0) 编辑
摘要: Notes:1. When check left shifting, do not use continue, but break it!!! Otherwise, you wil fall into infinite loop2. Initialize the map with T, not S!... 阅读全文
posted @ 2015-03-21 08:03 keepshuatishuati 阅读(149) 评论(0) 推荐(0) 编辑
上一页 1 ··· 23 24 25 26 27 28 29 30 31 ··· 36 下一页