摘要: 小细节太多了,需要注意!!! 阅读全文
posted @ 2018-03-02 10:59 mayinmiao 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 相同的时候,prev指针不动,cur.next = cur.next.next 不相同的时候, prev跟cur指针同时更新。 阅读全文
posted @ 2018-03-02 08:48 mayinmiao 阅读(104) 评论(0) 推荐(0) 编辑
摘要: Here, I used a helper function to help me get the tail node of duplicate number list. Store the prev and tail node. cur.next != null && cur.next.next 阅读全文
posted @ 2018-03-02 08:41 mayinmiao 阅读(86) 评论(0) 推荐(0) 编辑
摘要: 需要两个dummy node来构造两个list: 一个是小于target的linked list 另一个是大于等于target的linked list 阅读全文
posted @ 2018-03-02 08:08 mayinmiao 阅读(107) 评论(0) 推荐(0) 编辑
摘要: 1 public class Solution { 2 public ListNode insert(ListNode head, int value) { 3 // Write your solution here 4 if (head == null) { 5 return new ListNode(value); 6 ... 阅读全文
posted @ 2018-03-02 07:59 mayinmiao 阅读(82) 评论(0) 推荐(0) 编辑
摘要: 注意: merge的时候,cur1更新的位置不再是cur.next, 而是cur.next.next. 思考方式: (1) First, split the list into two sublists, using two pointers: fast and slow; Middle node 阅读全文
posted @ 2018-03-02 07:45 mayinmiao 阅读(93) 评论(0) 推荐(0) 编辑
摘要: 要点: 1. 出了第一个while loop后,要先判断fast指针的情况。 阅读全文
posted @ 2018-03-02 07:25 mayinmiao 阅读(91) 评论(0) 推荐(0) 编辑
摘要: 用到了两个dummy node。 阅读全文
posted @ 2018-03-02 07:09 mayinmiao 阅读(86) 评论(0) 推荐(0) 编辑
摘要: 这个题简单点,用个head.next.next传下去操作就可以了。 阅读全文
posted @ 2018-03-01 14:38 mayinmiao 阅读(84) 评论(0) 推荐(0) 编辑
摘要: 用快慢指针来判定是否有环。 这里while loop里的条件,用的是fast.next != null && fast.next.next != null,保证如果没有环,slow一定在中点。 阅读全文
posted @ 2018-03-01 14:27 mayinmiao 阅读(96) 评论(0) 推荐(0) 编辑