Quant Memo
Coding/●●●●●

Merge two sorted lists into a duplicate-free union

You are given the heads of two singly linked lists, each sorted ascending and each possibly containing repeats. Merge them into one ascending list in which every value appears exactly once, relinking existing nodes rather than copying payloads, and return the new head.

l1: 1 -> 2 -> 2 -> 4
l2: 2 -> 3 -> 4
->  1 -> 2 -> 3 -> 4

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

Your answer

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

More Coding questions