Lazy Bartender Algorithm
Let's reformulate this problem. We have a bipartite graph G(Drinks, Customers, E)
. Where edge e(i, j)
is in E
when drink i
is in the favorite set of the customer j
. And we want to find the minimum cardinality subset of Drinks
to cover all Customers
set.
This problem is a variation of Set cover problem (look at the Hitting set formulation). It is known to be NP-hard
, so there is no known polynomial algorithm.
Depending on constraints of the particular problem it can be solved with simple brute-force algorithm or dynamic programming/memoization approach, but you should know the exact constraints then.