top | item 40290689

(no title)

darrenkopp | 1 year ago

The data itself is ordered (which is why the task is to print them in order), but the order you receive the values is can happen in any order (ie the processing was split into multiple threads and each thread is posting back the results from the work).

discuss

order

tantalor|1 year ago

Ah then that's the classic "merge k sorted streams" question. It's a good question and easy to solve in a coding interview. Good candidate should be able to solve in about 30 minutes. My favorite solution goes something like "put values in a heap and then read them back out" because you only need to read 1 value from each stream at a time.

darrenkopp|1 year ago

Yep, that was my same approach as well.