Leetcode-Question-160: Intersection of Two Linked Lists

原文链接:
https://leetcode.com/problems/intersection-of-two-linked-lists/

题目描述:
160. Intersection of Two Linked Lists
Difficulty: Easy

Write a program to find the node at which the intersection of two singly linked lists begins.

For example, the following two linked lists:

begin to intersect at node c1.

Notes:

If the two linked lists have no intersection at all, return null.
The linked lists must retain their original structure after the function returns.
You may assume there are no cycles anywhere in the entire linked structure.
Your code should preferably run in O(n) time and use only O(1) memory.

解答:参考https://leetcode.com/discuss/17278/accepted-shortest-explaining-algorithm-comments-improvements

Updated:

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注