摘要: 1 class Solution { 2 public: 3 int removeElement(int A[], int n, int elem) { 4 int index = 0; 5 for (int i = 0; i < n; i++) { 6 ... 阅读全文
posted @ 2015-03-22 17:00 keepshuatishuati 阅读(120) 评论(0) 推荐(0) 编辑
摘要: Notes:1. Check when the loop finished. The last element still need to be remove.2. when remove the current one, do not forget to move the pointer back... 阅读全文
posted @ 2015-03-22 16:58 keepshuatishuati 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), ne... 阅读全文
posted @ 2015-03-22 16:13 keepshuatishuati 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 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 =... 阅读全文
posted @ 2015-03-22 16:09 keepshuatishuati 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 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 ... 阅读全文
posted @ 2015-03-22 16:06 keepshuatishuati 阅读(105) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2015-03-22 16:01 keepshuatishuati 阅读(259) 评论(0) 推荐(0) 编辑
摘要: 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 ... 阅读全文
posted @ 2015-03-22 15:53 keepshuatishuati 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 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 *... 阅读全文
posted @ 2015-03-22 15:43 keepshuatishuati 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2015-03-22 15:29 keepshuatishuati 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2015-03-22 15:24 keepshuatishuati 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 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 ... 阅读全文
posted @ 2015-03-22 15:19 keepshuatishuati 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2015-03-22 15:14 keepshuatishuati 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 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 ... 阅读全文
posted @ 2015-03-22 15:02 keepshuatishuati 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 void getP(vector > &result, vector &num, vector current, vector rec) { 4 if (num.size() == current.size())... 阅读全文
posted @ 2015-03-22 14:57 keepshuatishuati 阅读(125) 评论(0) 推荐(0) 编辑
摘要: Classical problem: 1 class Solution { 2 public: 3 void getP(vector > &result, vector &num, vector current, vector rec) { 4 if (current.siz... 阅读全文
posted @ 2015-03-22 14:52 keepshuatishuati 阅读(136) 评论(0) 推荐(0) 编辑
摘要: Follow the hint fromhttps://leetcode.com/discuss/24478/i-did-it-in-10-lines-of-c1. The last three digits of binary format will be :A 001C 011G 111T... 阅读全文
posted @ 2015-03-22 11:03 keepshuatishuati 阅读(113) 评论(0) 推荐(0) 编辑
摘要: Notes:1. Make a array to check whether they have same number of chars (s1[i] - 'a') and (s2[i] - 'a')2. When finally check, the i start from 1.3. It i... 阅读全文
posted @ 2015-03-22 10:48 keepshuatishuati 阅读(173) 评论(0) 推荐(0) 编辑