Website Pair with the Most Common Visitors
Problem statement
Each row of visits is [user, website]. A user may visit one website more than once, but contributes at most once to that website's visitor set.
Among all unordered pairs of distinct websites, return the pair with the largest number of shared visitors. Sort the two names inside the result. Break ties by the lexicographically smallest pair. Return an empty array when fewer than two distinct websites appear.
Function
mostCommonVisitorPair(visits: String[][]) → String[]Examples
Example 1
visits = [["u1","a"],["u1","b"],["u2","a"],["u2","b"],["u3","c"]]return = ["a","b"]Websites a and b share two visitors, more than any other pair.
Example 2
visits = [["u1","a"],["u1","a"],["u1","b"],["u2","b"],["u2","c"]]return = ["a","b"]Repeated visits by one user do not inflate an intersection.
Constraints
0 <= visits.length <= 50000- Every row contains exactly two nonempty strings.