Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a function to find the intersection of two linked lists.

Hard

Problem 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 }
Log in or sign up to run or submit your code.Log inSign up
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