Code RoomDNS name decoding
MediumPrep Room Coding #192

DNS name decoding

CodingNetworking & APIsAlgorithms & data structuresEntry–Mid~20 min

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.

0:00 of about 20 min
InputExpectedGot
[[3,119,119,119,7,101,120,97,109,112,108,101,3,99,111,109,0]]"www.example.com"not run yetsample