Code Room
CodingMediumcod-g1032
Subject Protocol framingLevel Mid–Senior~20 minCommon in Networking & APIs · Distributed systems interviewsIndustries Software development, Telecom

Question

Deframe a byte stream of length-prefixed messages. The input is a list of byte values. Each message is a single length-prefix byte N followed by exactly N payload bytes. Return a list of payloads (each a list of ints) in order. If the stream ends in the middle of a frame (fewer than N payload bytes remain), discard that trailing incomplete frame. A length byte of 0 yields an empty payload.

Implement
deframe(stream: list[int]) → list[list[int]]
Examples
in[[3,1,2,3,2,9,8]]out[[1,2,3],[9,8]]
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.