Group employees by shared interests
PalantirSoftware Engineer · Technical ScreenLast updated
This question evaluates a candidate's competency in organizing and querying collections, mapping relationships between entities, and reasoning about algorithmic time and space complexity within data structures and grouping operations.
Given N employees, each with an integer id and a set of interests (strings), write an algorithm to find all employees who share at least one common interest. Return either (a) a mapping from each interest to the sorted list of employee ids who have it, and/or (b) the list of all unique employee-id pairs (u, v) that share one or more interests. Analyze time and space complexity and provide code in your preferred language.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.