![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
Line290
这个作者很懒,什么都没留下…
展开
-
1. Two Sum
class Solution { public: vector twoSum(vector &numbers, int target) { vector ret(2,-1); unordered_map m; //value->index map for(int i = 0; i < numbers.size(); i ++)转载 2017-07-18 21:43:05 · 226 阅读 · 0 评论 -
2. Add Two Numbers
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode* ad原创 2017-07-18 21:44:16 · 212 阅读 · 0 评论 -
3. Longest Substring Without Repeating Characters
class Solution { public: int lengthOfLongestSubstring(string s) { if(s.size() == 0) return 0; if(s.size() == 1) return 1; int post[128] = {-1}; fill(post,post+128,-原创 2017-07-18 23:02:32 · 292 阅读 · 0 评论 -
Manacher's ALGORITHM: O(n)时间求字符串的最长回文子串
leetcode problem NO.5 一个很有意思的算法,马拉车算法。。。这名字2333 如果说利用到了回文串的对称性质还能接受,毕竟一个回文串的性质不多,还是会想到的 但是添加辅助字符操作很不一般 我认为发明者Manacher肯定是先觉得对称性很有用 然后千方百计想利用这一性质 然后肯定会设置一些辅助数组记录各个位置的信息 然后想到了“插空”我觉得他是不是之前刚好做了插空原创 2017-09-24 22:03:13 · 360 阅读 · 0 评论 -
4. Median of Two Sorted Arrays
参照http://blog.csdn.net/zxzxy1988/article/details/8587244 double findKth(int a[], int m, int b[], int n, int k){ if (m > n) return findKth(b, n, a, m, k); else if (m == 0) retu原创 2017-09-18 22:59:51 · 429 阅读 · 0 评论 -
5. Longest Palindromic Substring
class Solution { bool IsPalindrome(string s, int low, int high) { while(low <= high) { if(s[low] != s[high]) return false; low++; high--; }原创 2017-09-19 22:14:52 · 385 阅读 · 0 评论