Code Room
CodingMediumcod-g1511
Subject Config parsingLevel Entry–Mid~13 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Write the comment stripper for a dotfile format. In each line, a "#" begins a comment that runs to the end of the line — UNLESS the "#" sits inside a double-quoted region. Scanning left to right, each '"' toggles quoted mode (there are no escape characters, and a quote opened on a line may simply never close). After removing any comment, delete trailing spaces from what remains; keep leading whitespace untouched. Lines that end up empty disappear entirely. Return the surviving lines in their original order.

Implement
strip_inline_comments(lines: list[str]) → list[str]
Examples
in[["name=\"a # b\" # real comment","# full comment","port=80"]]out["name=\"a # b\"","port=80"]
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.