This was my last coding interview of the onsite process. Here's the question
Write a function that takes the following 3 queries:
1. manager, a, b -> represents that a is manager of b
2. peer, a, b -> both a and b have the same manager
3. is_manager a, b -> you should return whether a is manager of bAssume every input is valid.
Assume every query is coming one at a time, not a list of queries.
Interviewer said I might come across a case where a peer query came with two managerless employees
My answer was a class that had three global variables: managerless_people, peer_to_manager, managers that represented a connection between a and b. Lots of if statements and assignments.
My code wasn't the cleanest and I felt like my interviewer was not paying attention at all at what I was saying.
I don't feel like my code was the best but handled most of cases afaik.
I don't have any input example, just the three example queries above.
Wish me luck to get that offer!!!