Your question is Reverse Array or Flatten Object. 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.
Celebal Technologies frontend dashboards receive configuration data as nested JSON-like objects. Implement flatten_config to convert every nested dictionary or list value into a single dictionary whose keys use dot-separated paths.
The input is a JSON-like Python value containing dictionaries, lists, and primitive values: strings, numbers, booleans, or None. Dictionary keys are non-empty strings that do not contain a dot. A dictionary child uses its key in the path, and a list child uses its zero-based index. Return a dictionary mapping each leaf path to its original value.
Non-empty dictionaries and lists must be recursively expanded. Empty dictionaries and empty lists are treated as leaf values and should be preserved. The root input is always a dictionary. Do not mutate the input.
def flatten_config(config):