#468 Recursive Extraction of Pairs from a Nested Map
Write a function that accepts a dictionary containing keys and values and returns a list of all "key-value" pairs. If a value is a nested dictionary, the function must recursively extract keys and values from it.
Example:
Input:
data = {'a': 1, 'b': {'c': 2, 'd': {'e': 3}}, 'f': 4}
Output:
[('a', 1), ('c', 2), ('e', 3), ('f', 4)]
Question review
Sign in to start the dialogue
The mentor keeps the context of the current question and your previous messages.
Sign in
Available with Premium
This is just one of the solutions available with Premium. And more:
- 250+ advanced lectures
- 1300+ practice exercises
- 500+ solutions to problems from real interviews
- Personalized Java Hub certificates
- Expanded access to the AI mentor