Skip to content

Instantly share code, notes, and snippets.

@tawrahim
Created December 5, 2017 12:17
Show Gist options
  • Save tawrahim/5fcaa7e520d78584eb027e613c6ce931 to your computer and use it in GitHub Desktop.
Save tawrahim/5fcaa7e520d78584eb027e613c6ce931 to your computer and use it in GitHub Desktop.
Return a hierarchy of a given string separated by "."
public class KV {
  String key;
  String value;
}

/* Input:
      [
        new KV("foo.bar.baz", "james"),
        new KV("foo.blah", "Terry"),
        new KV("foo.bar.meow.height", "15"),
        new KV("foo.meow.size", "11")
      ]
      
    Output:
        foo: {
           bar: {
             baz: "james"
             meow: {
                height: 15
             }
           },
           blah: "Terry",
           meow: {
              size: 11
           }
        }
      
*/
public HashMap<String, ? extends Object> geHierarchy(KV[] dataset) {
 

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment