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

假期四个月计划 - 刷题|补基础|看网课|做项目

   
🔗
Song0427 2019-5-10 01:51:16 | 只看该作者
全局:
厉害啦,求组团 PS:为什么这个帖子加不了米米
回复

使用道具 举报

🔗
 楼主| Husky_wang 2019-5-10 03:06:58 | 只看该作者
全局:
本帖最后由 Husky_wang 于 2019-5-9 20:01 编辑

5.9 做题

27. Remove Element. This is a two pointers problem. Almost all char removal problem can use two pointers method. Slow pointer points to the index that all elements left to it should be returned, while fast pointer is the current index. In this case, we move the fast pointer each step and we move the slow pointer only if the fast pointer is pointing to the elements which should be returned. Copy it first to the slow then move the slow.

26. Remove Duplicates from Sorted Array. Still, removing duplicates is char removal problem and for almost all char removal problems we may consider to use two pointers method. We must know when should we move the slow pointer and what should we do when we move the slow pointer. In this case, fast pointer is the current index and if the value of fast is equal to the value of slow, which means we meet the duplicates, we need skip this element using fast pointer. When we find a new element next, we will want to keep it, so we will copy it to which index the slow pointer is pointing. What need to be careful about is whether we need copy first then move slow, or we need move slow first then copy. In this case we move first. It depends on the physical meaning of the slow pointer. Excluding or including.

80. Remove Duplicates from Sorted Array II. This problem require me to keep two elements for each duplicates. How should I deal with this case? May I solve this problem based on the Remove Duplicates from Sorted Array I? What's the difference between these two problem? First, both slow and fast pointers should start with index 2, since in any cases we need return at least two elements. Then, we need to compare value of fast with value of slow-2 (in this case I will return the solution excluding the slow), since there have been already two elements returned.

277. Find the Celebrity. The first step is to find the celebrity candidate. That is, we want to use one pass to find out all elements that violate the rule. So we will use two pointers to compare two index each time and exclude one of them that violates the rule. This is how I compare these two: if left knows right, left is not celebrity, move left++; if left doesn't know right, right is not celebrity, move right--. While loop this process till left == right. Now we find the candidate, which has not yet violated any celebrity rules. But since it has not yet been compared with all other element, we will want to make sure of that. Now we use another one pass to compare all other elements with the candidate. We will need to make sure 1) the celebrity doesn't know any of them; 2) all other elements should know the celebrity. If any of these rule are violated, the candidate is not celebrity and we just return -1.

189. Rotate Array. Actually this is a reverse problem. The tip is to find the rotate pivot, then reverse the first and second subarray. At last reverse the whole array so that we have result. This is just a trick to remember.



回复

使用道具 举报

🔗
 楼主| Husky_wang 2019-5-10 04:23:43 | 只看该作者
本楼:
全局:
本帖最后由 Husky_wang 于 2019-5-10 09:08 编辑

编辑掉了
回复

使用道具 举报

🔗
 楼主| Husky_wang 2019-5-10 04:24:05 | 只看该作者
本楼:
全局:
本帖最后由 Husky_wang 于 2019-5-10 09:18 编辑

。。。编辑
回复

使用道具 举报

🔗
 楼主| Husky_wang 2019-5-10 06:35:56 | 只看该作者
本楼:
全局:
本帖最后由 Husky_wang 于 2019-5-10 09:19 编辑

编辑了。。
回复

使用道具 举报

🔗
 楼主| Husky_wang 2019-5-10 08:33:17 | 只看该作者
本楼:
全局:
本帖最后由 Husky_wang 于 2019-5-10 09:18 编辑

编辑编辑
回复

使用道具 举报

全局:
Husky_wang 发表于 2019/05/10 01:32:46


同意,网课这种其实跟那些培训班没啥区别,只不过就是便宜一点而已……今年秋天继续找实习!

便宜的不是一点点
回复

使用道具 举报

🔗
neiyo 2019-5-10 13:02:37 来自APP | 只看该作者
全局:
我也在刷题准备中
回复

使用道具 举报

全局:
我和楼主很类似的现状,希望能一起加油,好好坚持!
回复

使用道具 举报

🔗
Airone 2019-5-10 16:23:51 来自APP | 只看该作者
全局:
我觉得有不错的实习就实习,尤其大公司,能学到不少,而且简历好看,我之前跟楼主一样哈,我是早上刷题,下午看网课,晚上健身开黑游戏
回复

使用道具 举报

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

本版积分规则

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