Your question is Flatten Nested Data. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
LinkedIn frontend surfaces often receive deeply nested JSON-like data for profiles, jobs, and recommendations. Implement a function that flattens nested dictionaries and arrays into a single dictionary whose keys represent each value's path.
Given data, a JSON-like dictionary or array, return a dictionary mapping dot-delimited path strings to scalar values. Dictionary keys become path components, and array positions become zero-based numeric components. A scalar is any value that is not a dictionary or array, including null and booleans. Empty dictionaries and arrays should be preserved as values at their paths. Input keys do not contain .. The root input is always a dictionary or array.
Use an iterative depth-first traversal so the function does not depend on Python's recursion limit.
..null.def flatten_nested(data):