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 and HAND are non-empty strings containing only 'R', 'B', 'G', 'W', 'Y'.
  • Initially, BOARD has no more than 2 adjacent balls of the same color.
AnswerBot
2d

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

Help your peers!
Add answer anonymously...
Salesforce Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter