Everyone who has ever worked in a large organization understands the organizational hierarchy: you, your boss, boss
of your boss, and so on.
Because of changes in all directions of the organization, everything was mixed up. From the existing documentation,
you can understand only who is a manager and who is a subordinate. We need your help to recreate the whole
organizational hierarchy using information from all existing documents.
The first argument is a path to a file. Each line includes a test case with documents separated by a pipeline '|'. There are two letters in each document: 1st one – the manager, 2nd one – the subordinate.
For example:
ab | ae | bc ab | bc | cd | ae | cx | xz
You should print the hierarchical tree in the following format: if a manager a has two subordinates e and b, then the tree would be a [b, e]. You should sort all workers alphabetically.
For example:
a [b [c], e] a [b [c [d, x [z]]], e]
- Hierarchical tree can be of no more than 4 levels.
- Sort all subordinates of one manager in an alphabetical order.
- The number of test cases is 15.