|
3 | 3 | import java.util.HashMap; |
4 | 4 | import java.util.Map; |
5 | 5 |
|
6 | | -/** |
7 | | - * 691. Stickers to Spell Word |
8 | | - * |
9 | | - * We are given N different types of stickers. Each sticker has a lowercase English word on it. |
10 | | - * You would like to spell out the given target string by cutting individual letters from your collection of stickers and rearranging them. |
11 | | - * You can use each sticker more than once if you want, and you have infinite quantities of each sticker. |
12 | | - * What is the minimum number of stickers that you need to spell out the target? If the task is impossible, return -1. |
13 | | -
|
14 | | - Example 1: |
15 | | - Input: |
16 | | - ["with", "example", "science"], "thehat" |
17 | | - Output: |
18 | | - 3 |
19 | | -
|
20 | | - Explanation: |
21 | | - We can use 2 "with" stickers, and 1 "example" sticker. |
22 | | - After cutting and rearrange the letters of those stickers, we can form the target "thehat". |
23 | | - Also, this is the minimum number of stickers necessary to form the target string. |
24 | | -
|
25 | | - Example 2: |
26 | | - Input: |
27 | | - ["notice", "possible"], "basicbasic" |
28 | | - Output: |
29 | | - -1 |
30 | | -
|
31 | | - Explanation: |
32 | | - We can't form the target "basicbasic" from cutting letters from the given stickers. |
33 | | -
|
34 | | - Note: |
35 | | - stickers has length in the range [1, 50]. |
36 | | - stickers consists of lowercase English words (without apostrophes). |
37 | | - target has length in the range [1, 15], and consists of lowercase English letters. |
38 | | - In all test cases, all words were chosen randomly from the 1000 most common US English words, and the target was chosen as a concatenation of two random words. |
39 | | - The time limit may be more challenging than usual. It is expected that a 50 sticker test case can be solved within 35ms on average. |
40 | | - */ |
41 | 6 | public class _691 { |
42 | 7 | public static class Solution1 { |
43 | 8 | /** |
|
0 commit comments