Find Unmet Users With Shared Interests
Updated
Problem statement
Find users who share an interest with user_id and have not directly met that user. Return their zero-based indices in increasing order.
For this exercise, assume users[i] is the list of interest names for user i. A shared interest means an exact, case-sensitive match of a full name. Duplicate names do not change a match. Exclude user_id itself.
For this exercise, assume each entry [a,b] in meetings records a direct meeting between those two users in either direction. Repeated pairs have no extra effect. Meeting someone who has met the target does not count as meeting the target.
Keep interest lookups array-based, as the follow-up asks. You may sort a copy and use binary search. A separate index for meeting history is allowed. User records are represented here by interest lists and a separate list of meeting pairs.
Function
search(user_id: int, users: String[][], meetings: int[][]) → int[]Examples
Example 1
user_id = 0users = [["hiking","music"],["music"],["hiking"],["chess"],["music","hiking"]]meetings = [[0,1]]return = [2,4]User 1 shares music but has already met the target. Users 2 and 4 share an interest and have no direct meeting with user 0. User 3 shares no interest.
Example 2
user_id = 1users = [["Art"],["art"],["art","art"]]meetings = [[2,1]]return = []User 0 has Art, which differs from art. User 2 has directly met user 1. The target itself is excluded.
Example 3
user_id = 0users = [[]]meetings = []return = []The target has no interests, and there are no other users.
Constraints
1 <= users.length <= 200.0 <= user_id < users.length.- Each user has
0to100listed interests. - Every interest name has
1to20English letters, uppercase or lowercase. 0 <= meetings.length <= 1000.- Every meeting entry has exactly two user indices.
0 <= meetings[j][k] < users.length.- The total number of interest-name occurrences across all users is at most
1000.
More Palantir interview questions
- Map and Accumulate Learning QueriesONSITE INTERVIEW · Seen Oct 2026
- Relational Learning QueriesONSITE INTERVIEW · Seen Apr 2025
- Maximum Profit with Repeated Stock TradesONSITE INTERVIEW · Seen Sep 2024
- Minimum Calls for Repeated API LookupsONSITE INTERVIEW · Seen Oct 2022
- Find Cookable RecipesONSITE INTERVIEW · Seen Nov 2019
- Simulate Multiplayer WarONSITE INTERVIEW · Seen Nov 2019
- Trace Terminal Company OwnershipONSITE INTERVIEW · Seen Nov 2019
- Query Words Within K PositionsPHONE SCREEN · Seen Nov 2026
- Basic Item DiscountsOA · Seen Nov 2026
- Optimize Discount Selection Under a Point BudgetOA · Seen Nov 2026
Similar questions at other companies
- Product Record SearchWells Fargo · OAWells Fargo interview questions
- Find the Words for Each PrefixDocuSign · PHONE SCREENDocuSign interview questions
- Filter Anagrams of a TargetMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Deduplicate Logs: Keep FirstGoogle · ONSITE INTERVIEWGoogle interview questions
- Loyal Customers by Two-Day Product VarietyAmazon · ONSITE INTERVIEW
- Count Points in Each Boundary IntervalBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
- Type-Ahead Prefix MatchesNavan · ONSITE INTERVIEWNavan interview questions
- Search a Sorted Array of WordsExpedia · ONSITE INTERVIEWExpedia interview questions
- 3Sum SmallerSalesforce · ONSITE INTERVIEWSalesforce interview questions
- Keyboard Autocomplete SuggestionsLyft · ONSITE INTERVIEWLyft interview questions