We are given N different types of stickers. Each sticker has a lowercase English word on it.
You would like to spell out the given
target string by cutting individual letters from your collection of stickers and rearranging them.
You can use each sticker more than once if you want, and you have infinite quantities of each sticker.
What is the minimum number of stickers that you need to spell out the
target? If the task is impossible, return -1.
["with", "example", "science"], "thehat"
We can use 2 "with" stickers, and 1 "example" sticker. After cutting and rearrange the letters of those stickers, we can form the target "thehat". Also, this is the minimum number of stickers necessary to form the target string.
["notice", "possible"], "basicbasic"
We can't form the target "basicbasic" from cutting letters from the given stickers.
stickershas length in the range
stickersconsists of lowercase English words (without apostrophes).
targethas length in the range
[1, 15], and consists of lowercase English letters.