Code RoomMerge sorted server logs
MediumPrep Room Coding #519

Merge sorted server logs

CodingAlgorithms & data structuresEntry–Mid~14 min

Two app servers each produce a log that is already sorted by time. Every line starts with an integer Unix-seconds timestamp, then a space, then the entry text — for example "95 cache warmed". Merge the two logs into a single list sorted by timestamp (numeric comparison — beware that comparing "9" and "100" as strings orders them wrongly). When a line from each server carries the same timestamp, place server A's line first. Preserve each server's internal order.

Implement
merge_log_streams(a: list[str], b: list[str]) → list[str]
Examples
in[["5 gateway up","100 request served"],["9 cache warm"]]out["5 gateway up","9 cache warm","100 request served"]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 14 min
InputExpectedGot
[["5 gateway up","100 request served"],["9 cache warm"]]["5 gateway up","9 cache warm","100 request served"]not run yetsample