Zuma Game Problem Statement
You have a string of balls on the table called BOARD
and several balls in your hand represented by the string hand
. The balls can be of the colors red(R), blue(B), green(G), white(W), and yellow(Y). Your objective is to clean the BOARD
by performing operations where you place a ball from hand
into BOARD
. If more than two consecutive balls of the same color touch, they are removed from the BOARD
, continuing until no further removals can be made or the board is cleared.
Determine the minimum number of insertions required to make the BOARD
empty. If it is not possible, return -1.
Example:
Input:
T = 1
BOARD = "WRRBBW"
HAND = "RB"
Output:
-1
Explanation:
With the given hand, it's not possible to empty the board.
Constraints:
1 <= T <= 10
1 <= |BOARD| <= 10
1 <= |HAND| <= 4
- Both
BOARD
andHAND
are non-empty strings containing only 'R', 'B', 'G', 'W', 'Y'. - Initially,
BOARD
has no more than 2 adjacent balls of the same color.
Determine the minimum number of insertions required to empty the board in Zuma game problem.
Check if it's possible to empty the board by trying all possible combinations of inserting balls from hand.
U...read more
Top Salesforce Software Developer interview questions & answers
Popular interview questions of Software Developer
Top HR questions asked in Salesforce Software Developer
Reviews
Interviews
Salaries
Users/Month