Feature #3: Balloon Splash
Implementing the "Balloon Splash" feature for our "Game" project.
Description
We have to develop the game named Balloon Splash. Assume that there are multiple colored balloons, and we have to shoot a column of balloons of the same color. We can only splash k
consecutive balloons of the same color. Once a set of k
consecutive balloons is splashed, any balloons above it will fall to replace them. We will keep shooting until it is not possible to shoot k
consecutive balloons of the same color. In the end, there will not be any k
consecutive balloons left. For this problem, our input will be in the form of the English alphabet. Each letter will represent a unique colored balloon.
Let’s go through the following illustration to understand this problem:
Solution
We are given a string string
and an integer k
, where the k
consecutive letters that are identical can be eliminated from the string string
. After removing the k
...
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.