Question bank › Recursion
Dsa Recursion Warm-up

Flatten a Dictionary

You have been given a dictionary which may contain nested dictionaries as values. Your task is to flatten this dictionary into a single-level dictionary where the keys are the concatenated keys from all levels, separated by dots. Input Format: A single line containing a dictionary representation in Python syntax. Output Format: A single dictionary in Python syntax. Example: Input: {'a': 1, 'b': {'c': 2, 'd': {'e': 3}}} Output: {'a': 1, 'b.c': 2, 'b.d.e': 3}

Key concepts

recursiondictionariesflattening

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.