Code Room
CodingMediumcod-g1331
Subject Log processingLevel Entry–Mid~14 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.