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

Question

Parse an INI-style config given as a list of lines. A line of the form '[name]' opens a section. A line 'key=value' assigns a key (keys/values are trimmed of surrounding spaces). Blank lines and lines whose first non-space char is '#' are comments to ignore. Keys before any section header belong to section ''. Later assignments overwrite earlier ones for the same (section,key). Return a sorted list of [section, key, value] triples (sort by section then key, both ascending).

Implement
parse_ini(lines: list[str]) → list[list]
Examples
in[["[db]","host = localhost","port=5432"]]out[["db","host","localhost"],["db","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.