Question
Reassemble a TCP byte stream from received segments. Each segment is [seq, data] where seq is the absolute byte offset of the first character of 'data'. Segments may arrive out of order and may overlap (when bytes overlap, the first-written byte wins). The stream begins at the smallest seq present. Return the longest contiguous prefix of the reassembled stream starting at that first byte, stopping at the first missing byte (gap). For empty input, return ''.
reassemble_segments(segments: list[list]) → str[[[0,"hello"],[5,"world"]]]out"helloworld"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.