Skip to content

List #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
caipengbo opened this issue Sep 4, 2019 · 5 comments
Open

List #13

caipengbo opened this issue Sep 4, 2019 · 5 comments

Comments

@caipengbo
Copy link
Owner

caipengbo commented Sep 4, 2019

主要内容

目录

@caipengbo caipengbo added this to the LeetCode First Time milestone Sep 4, 2019
@caipengbo
Copy link
Owner Author

caipengbo commented Sep 5, 2019

dummy node

头部设置哑指针 dummy node, 这样就不用在循环中每次判断头节点是否为空(边界检查问题),也就是说每个节点都有 pre 节点

@caipengbo
Copy link
Owner Author

caipengbo commented Sep 12, 2019

指针的操作

  • 链表的指针移动
  • 头插和尾部插入
  • 指针的删除

重要的点:

  1. 遍历指针 p 的边界判断 使用p != nullp.next != null
  2. 封尾操作,遍历完,是不是需要对尾部进行特殊操作

@caipengbo
Copy link
Owner Author

链表的拆分

ListNode p = head, q = head.next;
ListNode evenHead = head.next;
while (p.next != null && p.next.next != null) {
    p.next = p.next.next;
    q.next = q.next.next;
    p = p.next;
    q = p.next;
}
p.next = null;

@caipengbo
Copy link
Owner Author

caipengbo commented Sep 12, 2019

快慢指针

  • 判断是否有环
  • 判断环的第一个入口地址
  • 判断相交节点的第一个交叉点

@caipengbo
Copy link
Owner Author

caipengbo commented Sep 12, 2019

Merge

链表的归并(递归写法)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant