Code Room
CodingMediumcod-g217
Subject ParsingLevel Mid–Senior~25 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Parse a tiny INI-like config given as a single string. Lines are separated by '\n'. A line that is blank or starts (after no leading spaces) with '#' is ignored. A line of the form '[name]' opens a section. A line of the form 'key=value' assigns within the current section. Leading/trailing spaces around key and value are stripped; the value may itself contain '=' (split only on the first). Keys before any section header go into a section named ''. Later assignments to the same key in the same section overwrite earlier ones. Return a dict mapping section name to a dict of its key/value strings.

Implement
parse_ini(text: str) → dict
Examples
in["[db]\nhost = localhost\nport=5432"]out{"db":{"host":"localhost","port":"5432"}}
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.