In the Stickers to Spell Word coding problem, you are given a set of stickers, each with a word on it, and a target word. You can use any number of stickers, and you can cut out individual letters from them. You want to find the minimum number of stickers needed to spell the target word. If it's impossible, return -1.
This "Hard" problem is common at Google and Meta. It tests a wide range of skills: string manipulation, frequency counting, and most importantly, optimization via Dynamic Programming or Memoization. It also introduces the concept of Bitmask interview pattern, as the state of the "target word" (which letters are already covered) can be represented as a bitmask.
The most effective approach is BFS or DFS with Memoization, often using a Bitmask to represent the current state of the target word.
target.length(), where the -th bit is 1 if the -th character of the target is already covered.Target: "apple", Stickers: ["app", "let"].
Practice problems involving Bitmask, Dynamic Programming. These are common for tasks where you need to track the "coverage" of a small set of items (like the characters in a target word of length ).
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Maximum Score Words Formed by Letters | Hard | Solve | |
| Partition to K Equal Sum Subsets | Medium | Solve | |
| Shopping Offers | Medium | Solve | |
| Word Break II | Hard | Solve | |
| Distribute Repeating Integers | Hard | Solve |