Code Room
CodingMediumcod-g1031
Subject Protocol dns encodingLevel Entry–Mid~20 minCommon in Networking & APIs · Algorithms & data structures interviewsIndustries Software development, Telecom

Question

Decode a DNS-style domain name from its wire encoding. The input is a list of byte values (ints 0-255). A name is a sequence of labels; each label is one length byte followed by that many ASCII character bytes, and the name ends at a zero length byte. Reconstruct the dotted name (e.g. 'www.example.com'). The root (a single 0 byte) decodes to the empty string.

Implement
decode_dns_name(data: list[int]) → str
Examples
in[[3,119,119,119,7,101,120,97,109,112,108,101,3,99,111,109,0]]out"www.example.com"
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.