Wells Fargo interview question

coding problem is related to "Selling Products" — Minimize distinct IDs