Practice Zuma Game
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
The string board is a row of balls colored R, Y, B, G, or W, and hand contains the balls available to insert. On each turn, take one ball from hand and insert it anywhere in the row, including either end. Remove any consecutive group of at least three balls of the same color. If a removal forms another such group, keep removing groups until none remain. The goal is to empty the board. Return the fewest insertions needed using the available hand, or -1 if it is impossible.
Source: Zuma Game on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
board = "WRRBBW", hand = "RB"
-1
# Example 2
board = "WWRRBBWW", hand = "WRBRW"
2
# Example 3
board = "G", hand = "GGGGG"
2
Constraints
Related LeetCode Problems
Practice more problems similar to Zuma Game.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.