刷leetcode笔记之链表相交处查找
参考:
https://blog.csdn.net/fengxinlinux/article/details/78885764
时间复杂度 O(n)
使用的方法是:
- 先判断两个链表的最后一个node是不是在同一地址,顺便计算出两个链表的长度
- 找到两个链表的长度差diff,将更长的那个链表的头指针偏移diff个node
- 两个链表同时偏移,判断其node的指针是否相等
在Leetcode上编程注意事项:
4. 变量开始要初始化
5. 指针要判断是不是为NULL指针,这个参考:https://blog.csdn.net/weixin_42979679/article/details/88878896
Intersection of the single linked list.
die Kreuzung der einzelnen verketteten Liste