← Questions

Remove runs of repeated characters (1D candy crush)

0
MetaCodingLast asked Sep 2025

Repeatedly remove every run of at least k equal adjacent characters from a string until none is left, and return what remains. Removing a run can join two runs into a new one. Note that the whole run goes, not only k of it: with k = 3, abbbbc loses all four bs. A simpler version removes any group of two or more equal neighbours. Use a stack of (character, count).

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding