Code Room
CodingMediumcod-g683
Subject Data wranglingLevel Mid–Senior~30 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Flatten a nested dict into a single-level dict whose keys are dotted paths. Given a dict whose values are either scalars (int, str, bool) or nested dicts (arbitrarily deep), produce a flat dict mapping each leaf's full dotted key path to its scalar value. For example {'a': {'b': 1}} becomes {'a.b': 1}. An empty dict (at any level) contributes no keys. Return the flattened dict.

Implement
flatten_dict(d: dict) → dict
Examples
in[{"a":{"b":1,"c":2},"d":3}]out{"d":3,"a.b":1,"a.c":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.

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.