The first part was behavioral questions.
For coding, I was given a collection of records. Each record had two parts: an account and an attribute. Accounts with the same attribute could be linked. If one account had two attributes, the groups on both sides could be merged into one set. I had to find all the connected groups of accounts.
My brain got stuck during the problem, and the answer suddenly came to me after the interview ended. I was just not good enough; what can I do.
I think the answer should be to build two graphs first, then build the groups from the entries in the attribute map. Find the group for each unvisited item, using a queue and BFS inside.
Discussion
Loading comments…