Merge two streams, show each once
transcript
A phone gets notifications from two sources. Each source keeps its own time order. Some notifications come through both.
Compare the front of each stream. Take the one with the earlier time. Then move that stream's pointer.
Two items can share a second. The statement says stream A comes first. Follow it, and the output never changes.
Eight notifications arrive in all. Two of them are repeats of earlier ones.
Check the set before showing an id. If it is new, show it and store it. If it was seen, skip it.
One stream may end before the other. The rest of the other still follows. It needs the same seen check.
In the interview, say which stream wins a tie. Say what counts as a repeat. And say what the cost is.
Each item is looked at once. That is linear time overall. The set stores one entry for each id.
Follow the tie rule exactly. Show each id once. Full breakdown in the lecture.