Bought Together Most
items has columns order and product, with each product at most once per order. Return [a, b] with a < b alphabetically: the two products that share the most orders. If pairs tie, return the pair that comes first alphabetically (compare a, then b).
Example 1
items {"order":[1,1,1,2,2,3,3],"product":["tea","milk","jam","milk","tea","jam","milk"]}
returns ["jam","milk"]
jam and milk share orders 1 and 3. milk and tea share orders 1 and 2. Both pairs have 2, and jam, milk comes first alphabetically.
Constraints
2 <= len(items) <= 80- At least one order holds two products
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.