Quant Memo
Coding/●●●●●

Intersection of two sorted linked lists

You are given the heads of two singly linked lists, each sorted ascending with distinct values. Return a sorted list of the values that appear in both, using a single lockstep walk.

l1: 1 -> 2 -> 4 -> 8
l2: 2 -> 4 -> 6 -> 8
->  2 -> 4 -> 8

Target O(m+n)O(m + n) time and O(1)O(1) extra space beyond the output.

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions