Skip to content

Instantly share code, notes, and snippets.

@danmux
Created March 31, 2016 15:11
Show Gist options
  • Select an option

  • Save danmux/fc03e7d390ad7e1d05c5163f228c98b4 to your computer and use it in GitHub Desktop.

Select an option

Save danmux/fc03e7d390ad7e1d05c5163f228c98b4 to your computer and use it in GitHub Desktop.
Test
@danmux

danmux commented Mar 31, 2016

Copy link
Copy Markdown
Author

Live Coding Task 2

In Centralway everyone has a boss apart from the CEO (although technically he probably has to answer to investors…): you, your boss, boss of your boss, and so on.
From our internal documentation, you can understand only who is the direct manager of who. We need your help to recreate the whole company hierarchy using this information. There are two letters in each document: 1st one – the manager, 2nd one – an employee.
Task

Each line of the input is a separate test case. It includes a list of all relationships in the company.
Result/output should be a string representation of the company hierarchy
What if there are multiple people at the top of the company hierarchy, for example multiple Managing Partners?
Examples

Input:

ab | ae | bc
ab | bc | cd | ae | cx | xz
Output:

a [b [c], e]
a [b [c [d, x [z]]], e]

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