Merge sorted logs

Write codeEasy11 min

Your task

You sync workout data from two fitness trackers. Each device reports the minute-of-day for every exercise event it logged, already in increasing order. Given the two logs a and b, produce one combined chronological list containing every event from both devices (duplicates are kept, two devices can log the same minute). Walk both lists with one pointer each instead of concatenating and sorting. Example: a = [3, 10, 20], b = [5, 10, 25] gives [3, 5, 10, 10, 20, 25].

Examples

merge_event_logs(a: list[int], b: list[int]) -> list[int]
Example 1
Inputmerge_event_logs([3, 10, 20], [5, 10, 25])
Output[3, 5, 10, 10, 20, 25]