Unique Users Within Each IP Address
Updated
Problem statement
You are given parallel arrays ips and names. Each position describes a username seen at that IP address. A user counts as unique at an IP if no longer name at that IP starts with the user’s full name.
For this exercise, assume exact duplicate (IP, name) pairs describe the same user. Equal names do not exclude one another, and comparisons are case-sensitive. A name at a different IP cannot exclude this user.
Return one [IP, name] row for every surviving distinct pair, in the order its first occurrence appears in the input. If a name is a prefix of a longer name at its IP, omit all occurrences of that pair. Empty inputs return an empty array. Treat each IP label as an identifier. You do not need to parse it as an address.
Function
uniqueIpUsers(ips: String[], names: String[]) → String[][]Examples
Example 1
ips = ["a","a","b","a"]names = ["ann","anna","ann","bob"]return = [["a","anna"],["b","ann"],["a","bob"]]At IP a, ann prefixes anna. The same name at IP b has no longer competitor and remains.
Example 2
ips = ["x","x","x","y"]names = ["alex","alex","al","al"]return = [["x","alex"],["y","al"]]Duplicate x/alex appears once. x/al is excluded by alex, while y/al is independent.
Example 3
ips = []names = []return = []No observations produce no users.
Constraints
0 <= ips.length <= 500andnames.length = ips.length.- Each IP label has
1to40characters, using English letters, digits, periods, colons or underscores. - Each name has
1to40English letters or digits.
More Roblox Onsite Interview questions
- Most Frequent Call Path From Function Trace LogsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Design Search Autocomplete SystemPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Candy Crush Grid Matching and GravityPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Topological Sort with Secondary OrderingPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Most Frequent Call Stack Per ThreadPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Count and Score Distinct Hat AssignmentsONSITE INTERVIEW · Seen Sep 2026
- Rate Limiter Sliding Window With Per-Entity LimitsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Most Frequent Call Path in Interleaved LogsONSITE INTERVIEW · Seen Aug 2026
- Grid Pathfinding with Obstacles (DFS)PHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2026
- Maximize Distance to Closest Person — Return the SeatONSITE INTERVIEW · Seen Jun 2026
Similar questions at other companies
- Group AnagramsAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
- In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
- Longest Consecutive Login StreakAmazon · ONSITE INTERVIEW
- Transform Dotted Keys into a Nested MapProofpoint · ONSITE INTERVIEW
- Serialize and Deserialize a String Key-Value StoreByteDance · ONSITE INTERVIEWByteDance interview questions
- Group AnagramsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Build an Inverted Document IndexConfluent · ONSITE INTERVIEWConfluent interview questions
- Find Duplicate Element PairsGoogle · ONSITE INTERVIEWGoogle interview questions
- Filesystem Hash TreeCursor · PHONE SCREEN · ONSITE INTERVIEWCursor interview questions
- Sort Characters by FrequencySnap Inc. · ONSITE INTERVIEWSnap Inc. interview questions