Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
Use iterative divide and conquer. Merge pairs of adjacent lists in each round, doubling the interval each time. This reduces k lists to 1 in O(log k) rounds. Each round processes all N total nodes once via the two-list merge.
Merging pairs halves the number of lists each round, giving log k rounds. Each round touches all N nodes exactly once. This is more efficient than merging one list at a time, which would be O(N*k).
Updated Feb 2026