Trains the technique from
LeetCode 23Merge k Sorted ListsThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A monitoring fleet writes its signed temperature readings into shards. You receive streams, a list of those shards. Each shard is already laid out from lowest reading to highest, and a shard may carry nothing at all.
Fold the shards into a single array that runs from lowest reading to highest. Every reading is kept, so a value stored in three shards shows up three times in the result.
The shard count can be far larger than the readings inside any one shard, so pull from all shard fronts together rather than flattening first.
Example 1
Eight readings from three shards line up as one run, and the value 2 stays twice because two shards recorded it.
Example 2
The second shard supplies both of the two lowest readings before the first shard contributes anything.
Example 3
Repeats spread across shards are all retained, so the result holds three copies.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def merge_streams(streams: list[list[int]]) -> list[int]:public int[] mergeStreams(int[][] streams)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.