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

Question

Environments in a deploy file can borrow from one another. The file is sectioned: "[title]" opens a section, "key=value" (first "=", trimmed) assigns inside it, blanks and "#" lines do nothing, repeated keys keep the last value. Inside a section, the special key "inherit" names ONE other section to borrow from. Resolve lookup(section, key) as: the section's own value if assigned; otherwise the borrowed section's own value if that section exists and assigned it; otherwise "". Borrowing is single-hop — never follow the borrowed section's own "inherit". Lookups are never for the key "inherit" itself.

Implement
lookup_with_inherit(lines: list[str], section: str, key: str) → str
Examples
in[["[base]","timeout=30","[prod]","inherit=base","host=p.example"],"prod","timeout"]out"30"
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.