Let's create a small Zuma Game:
Given a sequence of different kind of gems (for example: ABCCCBBBBCCCBBAAAB), a player clicks on one gem, for example, the sixth gem, which is B), if its is part of 3 or more same kind of gems, it is cleared out.
Otherwise, nothing happens (here, with click on 6th gem, B, there are 4 B's, so they will be crushed).
If the clickled part is removed, the parts before and after will collide and if they are the same, they should be eliminated is same and 3+
The action shall continue recursively until no such recursive event is available.
e.g:
ABCCCBBBBCCCBBAAAB
ABCCC<--->CCCBBAAAB ==> ABCCCCCCBBAAAB
AB<------>BBAAAB ==> ABBBAAAB
A<-->AAAB ==> AAAAB
<--->B ==> BDoes a similar question exist on LeetCode? If yes, please let me know!