Source | https://www.algoexpert.io/questions/merging-linked-lists |
---|---|
Difficulty | Medium |
Category | Linked Lists |
You're given two Linked List of potentially unequal length. These Linked Lists potentially
merge at a shared intersection node. Write a function that returns the intersection
node or return None
/ null
if there is no intersection.
Each Linked List
node has an integer value
as well as a next
node pointing to the
next node in the list or to None
/ null
if it's the tail of the list.
Note: Your function should return an existing node. It should not modify either Linked List, and it should not create any new Linked Lists.
Sample Input
linkedListOne = 2 -> 3 -> 1 -> 4
linkedListTwo = 8 -> 7 -> 1 -> 4
Sample Output
1 -> 4 // The lists intersect at the node with value 1