Lazy Bartender Algorithm

In one of the interviews, I found the following problem. Please suggest me an algorithm for this. I do not need the code.

  • There are a number of Npossible drinks. (n1, n2 ..)
  • Has a Cnumber of regular customers.
  • Each customer has a fixed favorite set of drinks.
  • Bartender must create as few drinks as possible to meet the needs of all customers.

Example:

Cust1: n3,n7,n5,n2,n9  
Cust2: n5  
Cust3: n2,n3  
Cust4: n4  
Cust5: n3,n4,n3,n5,n7,n4    

Output: 3(n3,n4,n5)  
+6
source share
1 answer

. G(Drinks, Customers, E). e(i, j) E, i j. Drinks Customers.

( ). , NP-hard, .

/, .

+7

All Articles