Code RoomCount section names
EasyPrep Room Coding #724

Count section names

CodingAlgorithms & data structuresEntry–Mid~12 min

An audit script summarizes a sectioned settings file. Trimmed lines of the shape "[title]" begin a section (title trimmed; the same title may begin sections in several places — they pool together). "name=data" lines (first "=", both sides trimmed) add the name to whatever section is open; names appearing before any section pool under the empty-string section, which exists in the output only if it actually received a name. Empty lines and "#" lines add nothing, yet a section title still counts even when nothing follows it. Report each section mapped to how many DISTINCT names it holds.

Implement
section_key_counts(lines: list[str]) → dict[str,int]
Examples
in[["[app]","name=x","name=y","port=1","[db]"]]out{"db":0,"app":2}
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.

0:00 of about 12 min
InputExpectedGot
[["[app]","name=x","name=y","port=1","[db]"]]{"db":0,"app":2}not run yetsample