832. Zuma Game (Recursive DP)

HardRecursionRecursion

Given Zuma board string, return min balls to insert to clear all.

Input: Quoted string of R/G/B/Y/W.

Output: Integer.

Examples

Example 1
Input: "WRRBBW"
Output: 2
Explanation: 2 insertions.
Example 2
Input: "G"
Output: 2
Explanation: Need 2 more G.
Example 3
Input: ""
Output: 0
Explanation: Empty.

Constraints

Asked by

GoogleAmazon
Solve this problem in the editor →