摘要:
From each pointer, spread to the board. One tricky is set the char that used to be 0. Set it back when finished searching. 1 class Solution { 2 privat... 阅读全文
摘要:
1 class Solution { 2 public: 3 string convert(string s, int nRows) { 4 if (nRows < 2) return s; 5 int len = s.size(), size = 2*nR... 阅读全文
摘要:
Do the BFS and use a hashset to record whether the word has been found before. 1 class Solution { 2 public: 3 int ladderLength(string start, strin... 阅读全文
摘要:
Do not confused with min cut again!!!!!!!!!!!! 1 class Solution { 2 public: 3 bool canBreak(string s, unordered_set &dict) { 4 int len = s... 阅读全文
摘要:
Differentiate it with Palindrome min cut!!!!!!!!! 1 class Solution { 2 public: 3 bool wordBreak(string s, unordered_set &dict) { 4 int len... 阅读全文
摘要:
Inorder traversal the tree and compare one by one. 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *l... 阅读全文
摘要:
Everytime forget to - '0'!!!!!!! 1 class Solution { 2 public: 3 bool isValid(vector &rec, int value) { 4 if (value > &board) {10 ... 阅读全文
摘要:
1 class Solution { 2 public: 3 bool isValid(string s) { 4 int len = s.size(); 5 if (len%2 == 1) return false; 6 stack lis... 阅读全文
摘要:
1 class Solution { 2 public: 3 string preProcess(string s) { 4 string result; 5 for (int i = 0; i = 'a' && s[i] = '0' && s[i] = '... 阅读全文
摘要:
Logic is tricky. Redo it. 1 class Solution { 2 public: 3 bool isNumber(string s) { 4 int start = 0, end = s.size()-1; 5 if (end ==... 阅读全文
摘要:
We can use a matrix do the dp. Or we can use an array to record it.But when we encounter 1, we set it to be 0. 1 class Solution { 2 public: 3 int ... 阅读全文
摘要:
1 class Solution { 2 public: 3 int uniquePaths(int m, int n) { 4 vector dp(m, 1); 5 for (int i = 1; i < n; i++) { 6 f... 阅读全文