Loading
Loading
Two sorted processing chains must be combined into a single sorted chain, reusing the existing nodes.
Return the head of the merged chain.
a = 1 → 3 → 5, b = 2 → 4compare 1 and 2take 1compare 3 and 2take 2compare 3 and 4take 3b exhaustedappend the rest of a1 → 2 → 3 → 4 → 5Sign in to keep a note here. It is free, and nobody else can see it.
Sign inExample 1
Sign in to open hints.
Struggling is where the learning happens. Open this once you have genuinely tried, or once the hints have run out.
O(n + m) time · O(1) space
Input. Run your code to watch it work on this input, one line at a time.
Running code is turned off on this deployment. You can still read the problem, write code, use hints and the visualizer.
Tab moves focus out of the editor. Press Ctrl+M to let Tab indent instead.
No results yet
Run your code against the sample tests, or submit to run the full suite.
Example 2
One chain empty.
Example 3