LC 23

Merge k Sorted Lists

Hard · LC 1–100

divide-and-conquerheap-priority-queuelinked-listmerge-sort
Free

Candidate solution routes

Primary

Linked-List Pointer Rewiring

Free

Invariant: prev bounds the correctly processed chain and cur is the first unprocessed node; every original node belongs to exactly one side and remains reachable.

candidate confidence: 0.625 · metadata_only

Alternate 1

K-way merge heap

Free

Invariant: The heap contains exactly the first unconsumed item of every source that still has data; the global minimum unconsumed item is therefore in the heap.

candidate confidence: 0.740 · metadata_only

Alternate 2

Merge-sort cross-half counting

Free

Invariant: At combine entry, both halves are sorted and internally counted. The relation pointer only advances; at exit every cross pair is counted exactly once and the parent range is sorted.

candidate confidence: 0.740 · metadata_only

Alternate 3

Divide, recurse, and combine

Free

Invariant: solve(lo,hi) returns a complete summary conforming to its domain contract; combine depends only on child summaries and accounts for every cross-domain contribution exactly once.

candidate confidence: 0.630 · metadata_only

How to use this page

Read the statement and constraints first, then validate recognition signals, invariant, and complexity. Candidate score is not correctness evidence.