Given a string with employee id, name and manager name, print out all of them in the tree format.
Input:
“1:Max:4, 4:Ann:0, 2:Jim:4, 3:Tom:1”
1 -> employee id
Max -> name
4 -> manager id
Output:
Ann
- Max
– Tom - Jim
I got stuck on how to get the top level of the manager in the output. Interviewer told me that I could regard the one with emId 0 to be the top one.
I didn’t finish my code though because I misunderstood the output format. I thought the output was like this which was wrong. I wasted time on re-thinking about it.
Ann
- Max
- Jim
Max - Tom