Write a function to find the intersection of two linked lists.
HardProblem Statement
Write a function to find the intersection of two linked lists.
Sample Input
Two linked lists: List A: 1 -> 2 -> 3 -> 4 -> 5 List B: 9 -> 8 -> 3 -> 4 -> 5
Sample Output
Intersection starts at node with value: 3
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
class ListNode(val value: Int) {
var next: ListNode? = null
}
fun findIntersection(headA: ListNode?, headB: ListNode?): ListNode? {
// Add your code here to find the intersection node
}
fun main() {
// Build linked lists and test the function
}
Input
Two linked lists: List A: 1 -> 2 -> 3 -> 4 -> 5 List B: 9 -> 8 -> 3 -> 4 -> 5
Expected Output
Intersection starts at node with value: 3