File tree 1 file changed +3
-13
lines changed
1 file changed +3
-13
lines changed Original file line number Diff line number Diff line change 1
1
"""
2
- Write a program to find the node at which the intersection of two singly linked lists begins.
3
- For example, the following two linked lists:
4
- A: a1 → a2
5
- ↘
6
- c1 → c2 → c3
7
- ↗
8
- B: b1 → b2 → b3
9
- begin to intersect at node c1.
10
- Notes:
11
- If the two linked lists have no intersection at all, return null.
12
- The linked lists must retain their original structure after the function returns.
13
- You may assume there are no cycles anywhere in the entire linked structure.
14
- Your code should preferably run in O(n) time and use only O(1) memory.
2
+ Given two singly linked lists, determine if the two lists intersect. Return the intersecting node. Note that the intersection
3
+ is defined based on reference, not value. That is, if the kth node of the first linked list is the exact same node (by reference)
4
+ as the jth node of the second linked list, then they are intersecting.
15
5
"""
16
6
def getIntersectionNode (headA , headB ):
17
7
if headA == None or headB == None :
You can’t perform that action at this time.
0 commit comments