#468 Recursive Extraction of Pairs from a Nested Map

Companies:
Kvando
Themes:
JavaCollections & GenericsPractice

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

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in