Update Leetcode 题解 - 链表.md

This commit is contained in:
张三思 2019-06-04 13:13:25 +08:00 committed by GitHub
parent 79c83e70e4
commit 826f812bd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,6 +42,8 @@ public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
return l1; return l1;
} }
``` ```
> 上面的代码默认了链表l1和l2存在交点在实际的Leetcode代码检测中是有两个链表没有相交的情况的所以要先检查是否相交否则会陷入死循环
还要判断链表l1和l2是否传入为空值否则也会出现问题
如果只是判断是否存在交点,那么就是另一个问题,即 [编程之美 3.6]() 的问题。有两种解法: 如果只是判断是否存在交点,那么就是另一个问题,即 [编程之美 3.6]() 的问题。有两种解法: