总结
- dummy node以防链表头不确定
- 两个指针, prev 和curt 同向移动.
- linkedlist的递归有时候会很省事. 但是如果头指针有可能改变的话, 便会有点麻烦, 需要将信息向下传递
- 反转或者删除结点的时候, 还需要定义prev指针
- 可以讲list打散重组, 新创建n个dummy node, 满足条件a的放在a链, b条件放在b链, 然后合并
- 建dummy node只是O(1) space
- LinkedList 总结:
- 对A节点操作, 需要找到A节点的前一个节点
- 排序需要用Merge sort
- fast = head.next; slow = head;
- 从末尾开始的第n个, 就是从头开始的第len - n个
- 交换两个节点, 必须先调换prev节点的next节点, 再调换当前target节点的next节点
- LinkedList:
- add() Appends the specified element to the end of this list.
- remove()
- poll()
- pop() Retrieves and removes the head (first element) of this list.
题目
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List II




