摘要:
1 class Solution { 2 public: 3 int removeDuplicates(int A[], int n) { 4 if (n < 3) return n; 5 int index = 1, rec = A[0], count =... 阅读全文
摘要:
1 class Solution { 2 public: 3 int removeDuplicates(int A[], int n) { 4 if (n < 2) return n; 5 int rec = A[0], index = 1; 6 ... 阅读全文
摘要:
This question is different from Regular Expression Matching.Because this does not need totally match. We just have to much p is part of s. 1 class Sol... 阅读全文
摘要:
Do not confused with check if (*p == '\0') return *s == '\0';p is the format that used to match. If p is already reaching end, s still has some chars ... 阅读全文
摘要:
1. Use two vectors to store the nodes and values. Sort the values. 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 *... 阅读全文
摘要:
Since it need to record the previous chars, we just have to maintain a queue. Actually, the number of left chars are no larger than 4. 1 // Forward de... 阅读全文
摘要:
Read the buffer from file every time. After loop terminated, check whether the total lens is over 4.Then use n - len (a negative number) to set the en... 阅读全文
摘要:
1 class Solution { 2 public: 3 double pow(double x, int n) { 4 bool sign = false; 5 if (n 0) {11 if (n%2 == 1) {12 ... 阅读全文
摘要:
I and two can use exactly same code. 1 /** 2 * Definition for binary tree with next pointer. 3 * struct TreeLinkNode { 4 * int val; 5 * TreeLink... 阅读全文
摘要:
Assign a new vector as the size is length + 1. Because if the original is 9999...., the it will have one digit more. 1 class Solution { 2 public: 3 ... 阅读全文