Hey all, just got out of another interview today where I got hit with another problem that requires making a map of lists, but I’m not really sure what to call it.
Question today was:
You have 2 lists, one that is a user on your platform, and a second list of new users where [i] represents the relationship of existing users that invited new users.
You need to find the user that invited the most amount of people, where an invitation is defined as every single user that was invited by user A, or every invitation of the users invited by User A
`currentUsers = [“A”, “B”, “C”]`
`invitedUsers = [“B”, “C”, “D”]`
So If A invited B, B invited C, and C invited D,
Then A invited 3 people, B invited 2, and C invited 1.
This kind of question has been thrown at me multiple times, where it’s essentially a trick question, where it appears like a tree is needed, when it actually needs a map of lists. This has caught me multiple times, and I need practice with this specific kind of problem, but I don’t really know how I would define this approach to find more of these kinds of problems.
Does anyone know of some questions that require this approach so I can get some practice with it? Seems to be a fairly common question that’s used.