text. When two neighbouring balls are the same, they pop and the rest close the gap, which may bring new equal neighbours together.
Pairs keep popping until no equal neighbours remain. Return the string of balls that are left. It can be shown that the result does not depend on the order in which pairs pop.text="kayyak" → ''
Remove yy to get kaak, then aa to get kk, then kk leaves an empty string.
text="abccbd" → 'ad'
Removing cc brings the two bs together; they go too, leaving ad.
text="xyz" → 'xyz'
text consists of lowercase English letterstext="kayyak"
''
Run checks the first 3 tests in your browser. Submit checks all 43 tests on the server, hidden ones included.