I had a placement OLT recently where I was asked the following question as 2nd of 3 questions. As it was campus placement and the time limit was 3 questions in 40 mins. I don’t think the question is something way too difficult but something is just not hitting in the solution. The Question goes on like:
In a certain pub, a lazy bartender serves drinks to costumers.
Each customer has a set of drinks he likes and would be satisfied only if he gets one of those.
What is the least number of distinct drinks bartender has to prepare to make all consumers happy.
First-line contains an integer N, the total number of drinks available.
Second-line contains an integer C, the total number of costumers.
next C-lines for each of ith costumer contain:
- an integer c[i] for total number drinks the customer likes
- next c[i] integers are the list of drinks the customer likes.
1 \leq N \leq 1000
1 \leq C \leq 10000
PS the test is over and I am asking the question in sheer curiosity and just to learn for other tests coming up.