36. Merge Two Incident Timelines
EasyEvent streams
Two teams provide timelines of [timestamp, message] pairs, each sorted by timestamp. Merge the timelines into one list ordered by timestamp.
Keep original order within a timeline. At an equal timestamp, take all matching primary entries before matching secondary entries. Keep duplicates and leave the inputs untouched.
Example 1
Input: primary = [[1,"start"],[4,"flag"],[4,"check"]], secondary = [[2,"alert"],[4,"page"],[8,"close"]] Output: [[1,"start"],[2,"alert"],[4,"flag"],[4,"check"],[4,"page"],[8,"close"]]
Example 2
Input: primary = [[3,"seen"]], secondary = [[3,"seen"]] Output: [[3,"seen"],[3,"seen"]]
Constraints
Each timeline has at most 100,000 entries.Timestamps are integers in [0, 10⁹].