楼主: lchen77
跳转到指定楼层
上一主题 下一主题
收起左侧

New Year, New Start. Leet Code Records (3-5 per day)

🔗
 楼主| lchen77 2019-1-8 13:56:37 | 只看该作者
全局:
2019-01-07:
1). 34. Find First and Last Position of Element in Sorted Array
2). 36. Valid Sudoku
3). 38. Count and Say
4). 39. Combination Sum
5). 40. Combination Sum II        
回复

使用道具 举报

🔗
 楼主| lchen77 2019-1-7 12:54:45 | 只看该作者
全局:
2019-01-06
1). 17. Letter Combinations of a Phone Number
2). 19. Remove Nth Node From End of List
3). 20. Valid Parentheses
4). 21. Merge Two Sorted Lists
5). 22. Generate Parentheses
6). 23. Merge k Sorted Lists
7). 26. Remove Duplicates from Sorted Array
8). 28. Implement strStr()
9). 29. Divide Two Integers
10). 33. Search in Rotated Sorted Array
This is the second round, post the one that improved.
  1. class Solution {
  2. public:
  3.     int strStr(string haystack, string needle) {
  4.         const int size_h = haystack.size();
  5.         const int size_n = needle.size();
  6.         if (0 == size_n) return 0;
  7.         vector<int> lps(size_n, 0);
  8.         for (int i = 1; i < size_n; i++) {
  9.             int pos = lps[i-1];
  10.             while (pos > 0 && needle[pos] != needle[i]) pos = lps[pos - 1];
  11.             if (needle[pos] == needle[i]) lps[i] = pos + 1;
  12.         }
  13.         int idx_h = 0, idx_n = 0;
  14.         for (; idx_h < size_h; idx_h++) {
  15.             while (idx_n > 0 && needle[idx_n] != haystack[idx_h]) idx_n = lps[idx_n - 1];
  16.             if (needle[idx_n] == haystack[idx_h]) idx_n++;
  17.             if (idx_n == size_n) return idx_h - size_n + 1;
  18.         }
  19.         return -1;
  20.     }
  21. };
复制代码
回复

使用道具 举报

🔗
 楼主| lchen77 2019-1-6 14:05:57 | 只看该作者
全局:
2019-01-05
1). 2. Add Two Numbers
2). 3. Longest Substring Without Repeating Characters
3). 5. Longest Palindromic Substring  
4). 7. Reverse Integer
5). 8. String to Integer (atoi)
6). 10. Regular Expression Matching
7). 11. Container With Most Water
8).13. Roman to Integer  
9). 14. Longest Common Prefix
10). 15. 3Sum
回复

使用道具 举报

🔗
 楼主| lchen77 2019-1-5 13:38:07 | 只看该作者
全局:
Happy Friday, Have a rest today.
回复

使用道具 举报

🔗
 楼主| lchen77 2019-1-4 15:44:29 | 只看该作者
全局:
2019-01-03:
1). 68 Text Justification
2). 289 Game of Life
3). 290 Word Pattern
4). 1 Two Sum
5). 4 Median of Two Sorted Arrays
回复

使用道具 举报

🔗
 楼主| lchen77 2019-1-3 13:20:40 | 只看该作者
全局:
2019-01-02
1).  284 Peeking Iterator   
2).  285 Inorder Successor in BST
3).  286 Walls and Gates
4).  287 Find the Duplicate Number  
5). 288        Unique Word Abbreviation  
回复

使用道具 举报

🔗
 楼主| lchen77 2019-1-2 14:07:31 | 只看该作者
全局:
love1point 发表于 2019-1-2 08:42
楼主是学生吗?还是在职刷题

zai zhi shua..........
回复

使用道具 举报

全局:
楼主是学生吗?还是在职刷题
回复

使用道具 举报

🔗
 楼主| lchen77 2019-1-2 08:17:35 | 只看该作者
全局:
加油,给所有新年还在刷题的鞋童们点赞。 一定会收获dream offer
回复

使用道具 举报

🔗
annig 2019-1-2 07:28:56 | 只看该作者
全局:
加油!也刚做了wiggle sort哈哈
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表