Google Telephonic round
Anonymous User
2582

Hey,
I appeared for the google's telephonic round interview recently, and got a question on trees. As it was bit tricky

Note- Can't disclose question due to confidentaility. Have to keep it under wraps.

Question- -- Find the root of tree so it become a valid binary tree. if it is an acyclic undirected graph having at most 3 neighbours.

example - 2->3,4
5-> 2,3,1
I don't remember the exact example but it is just a raw sample how input was given like.

I was very nervous as didn't want to lose this opportunity. The interviewer allowed me to write method and take the input sample in my own way. it was very confusing initally to understand him. I asked him about bit more clarity about it and he told me to do as I like it.
After few minutes i came up with an aproach having it stored it list of list .
My response was extremely confusing as it seems to be very new and unseen but tried to figure it out, i told him with a hashing and dfs it could be done and also told him that if it would be cyclic one we could have done with topological sort.

I told him about counting indregree and he answered as there could be multiple such nodes which have 2 neighbours. We have to return one of such valid binary tree root.

After exlaining me aproach to him and i started coding but then it was time up.

Next day, my recruiter told me the interview feedback was negative and shared some points of feedback interviewer gave.

Solutions to above question are most welcomed, also it would be great if someone will help me with the resources where i can solve such kind of problems.

Comments (11)