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
4mo

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!
Select
Add answer anonymously...

Salesforce Software Developer interview questions & answers

A Software Developer was asked Q. Pair with Given Sum in a Balanced BST Problem Statement You are given the ‘root’...read more
A Software Developer was asked Q. What is the difference between Early Binding and Late Binding in C++?
A Software Developer was asked Q. What is meant by multitasking and multithreading in operating systems?

Popular interview questions of Software Developer

A Software Developer was asked Q1. Pair with Given Sum in a Balanced BST Problem Statement You are given the ‘root’...read more
A Software Developer was asked Q2. What is the difference between Early Binding and Late Binding in C++?
A Software Developer was asked Q3. What is meant by multitasking and multithreading in operating systems?
Salesforce Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

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

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits