摘要:
1 class Solution { 2 public: 3 int maxProfit(vector &prices) { 4 if (prices.size() < 2) return 0; 5 int len = prices.size(), resu... 阅读全文
摘要:
Need a helper function to return the binary tree maximum height. If the return value is -1, it means there is a imbalanced subbranch . 1 /** 2 * Defi... 阅读全文
摘要:
Use a hash table to record it. The tricky part is that when the hash value is > 0, it is the index + 1. Otherwise, that string already exists in resul... 阅读全文
摘要:
Same with add binary. You can also skip delete the result pointer. But just return result->next. Depends on the interviewer. 1 /** 2 * Definition for... 阅读全文
摘要:
This question is pretty straight forward. 1 class Solution { 2 public: 3 string addBinary(string a, string b) { 4 int runnerA = a.size()-1... 阅读全文
摘要:
To be honest, I dont like this problem. This is just an extra layer loop for 3sum. But two mistakes I had made…..1. when skip j, use condition j > i+1... 阅读全文
摘要:
This problem is almost like 3sum. Actually it needs the same skip steps for j and k. But LeetCode did not put the test case there. So just put like th... 阅读全文
摘要:
For this problem, do not forget to skip the duplicates for i. Usually I will do duplication removal for j and k.Tag it. 1 class Solution { 2 public: 3... 阅读全文