Hard · Streams & I/O

Merge K sorted streams in one

Given k streams (lists) of integers, each sorted in ascending order and possibly empty, return a single ascending list containing every value from all the streams, duplicates included.

Examples

Example 1

[[1,4,7],[2,5,8],[3,6,9]]

Output: [1, 2, 3, 4, 5, 6, 7, 8, 9]

Example 2

[[1,10],[2,3,4]]

Output: [1, 2, 3, 4, 10]

Rebuild it in the studio

Open every published interview problem, solution, scene, and memory room free, with no account.

More Streams & I/O problems