Merge K Sorted Lists

Hard
Linked Lists Heap Divide and Conquer
Merge k sorted linked lists into one sorted list. Input: k lines, each space-separated sorted list Output: single sorted list

Constraints

See problem-specific constraints. Optimized solution required.

Examples

Example 1:
Input: 1 4 5 1 3 4 2 6
Output:
Example 2:
Input: 1 4 5 1 3 4 2 6
Output:

Hints

Consider a heap approach.
Think about time complexity.
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.