Given few sets and a number n:
Here assume n is 5:
a - (0,1,2)
b - (0,1,2,3)
c - (1,3,4,5)
d - (0,1,2,4)
e - (2,3,4,5)
f - (3,5)
Now if we take just b and c we get the entire range from 0 to 5.
I was thinking of a greedy approach but that does not seems to fit here.
This is the set cover problem and, as such, NP-complete, meaning you have to consider every possible solution and choose the minimum.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With