Problem Statement | |||||||||||||
Note to plugin users: there is an image in this problem statement. Please view the statement in the applet to see the image There is a collection of multi-colored stamp pads at the local craft store. Each pad has 5 colors on it, arranged as pie wedges (see picture). The wedges can be switched out with other wedges, so you can create the ultimate blend of colors for your favorite stamp. You have a wish list of certain colors, but each pad set is expensive, so you want to minimize the cost. Given the colors of each pad and the colors you want, return the minimum number of pad sets that you must buy in order to get the right colors. Here is an example of a stamp pad that you can buy:
You will be given a String[] pads, and a String[] wishlist. Each element in pads represents a stamp pad with 5 colors on it. Each pad will be in the format: "<color> <color> <color> <color> <color>" Each <color> will be a String of lower case letters 'a' - 'z', and the colors will be separated by single spaces. For example, the above stamp pad would be represented by the String: "yellow red purple blue cyan" Each element of wishlist is a color that you wish to own. Your method should return the minimum number of pads you must buy to get all the colors in wishlist, or -1 if it is not possible to do. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | pads will have between 1 and 20 elements, inclusive. | ||||||||||||
- | Each element in pads will have between 9 and 50 characters, inclusive. | ||||||||||||
- | Each element in pads will consist of exactly 5 color names separated by single spaces. | ||||||||||||
- | Each color name in pads will have between 1 and 15 characters, inclusive, and will consist of only lowercase letters 'a'-'z', inclusive. | ||||||||||||
- | There will be no repeated color names in a single element of pads | ||||||||||||
- | wishlist will have between 1 and 25 elements, inclusive. | ||||||||||||
- | Each element of wishlist will have between 1 and 15 characters, inclusive, and will consist of only lowercase letters 'a'-'z', inclusive. | ||||||||||||
- | There will be no repeated elements in wishlist. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
|