Code Room
CodingMediumcod-g1144
Subject Networking protocolsLevel Mid–Senior~25 minCommon in Networking & APIs · Algorithms & data structures interviewsIndustries Software development, IT services

Question

Parse a multipart/form-data request body. Parts are separated by a delimiter line '--' + boundary; the body ends with '--' + boundary + '--'. Each part has headers and a value separated by a blank line (CRLF CRLF); one header line is 'Content-Disposition: form-data; name="<field>"'. Each part is framed by a leading and trailing CRLF around the boundary. Given the raw body string and the boundary token, return a list of [field_name, value] pairs in order. Values may be empty or contain CRLFs.

Implement
parse_multipart(body: str, boundary: str) → list[list[str]]
Examples
in["--X\r\nContent-Disposition: form-data; name=\"field1\"\r\n\r\nvalue1\r\n--X\r\nContent-Disposition: form-data; name=\"field2\"\r\n\r\nvalue2\r\n--X--\r\n","X"]out[["field1","value1"],["field2","value2"]]
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.