Skip to content

Instantly share code, notes, and snippets.

@shurane
Created August 15, 2016 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shurane/6d35b77449d6986a2747ede961aac1c1 to your computer and use it in GitHub Desktop.
Save shurane/6d35b77449d6986a2747ede961aac1c1 to your computer and use it in GitHub Desktop.
interview problems

##Flatten a Dictionary

Given a dictionary, write a function to flatten it. Consider the following input/output scenario for better understanding:

Input:

{
  'Key1': '1',
  'Key2': {
    'a' : '2',
    'b' : '3',
    'c' : {
      'd' : '3',
      'e' : '1'
      }
    }
}

Output:

{
  'Key1': '1',
  'Key2.a': '2',
  'Key2.b' : '3',
  'Key2.c.d' : '3',
  'Key2.c.e' : '1'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment