Suppose C
refers to a set of containers {c1,c2,c3....cn}
, where each of these containers contains a finite set of integers {i1,i2,i3...im}
. Further, suppose that it is possible for an integer to exist in more than one container. Given a finite set of integers S
{s1,s2,s3...sz}
, find the size of the smallest subset of C
that contains all integers in S
.
Note that there could be thousands of containers each with hundreds of integers. Therefore, brute force is slow for solving this problem.
I tried to solve the problem using Greedy algorithm. That is, each time I select the container with the largest number of integers in the set S
, but I failed!
Can anyone suggest a fast algorithm for this problem?