Remove Adjacent Runs Repeatedly
Practice Remove Adjacent Runs Repeatedly for free on NudgeCode: Medium, Stack pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
Given a string s, whenever two or more equal characters are next to each other, delete that whole run, keeping none of them. After a deletion the characters on either side may form a new run; keep deleting, scanning from left to right, until nothing can be deleted. Return the final string.
Example
s = "abbbaaccz" -> "z"
Delete bbb to get "aaaccz"; the first a now joins aa into aaa, which goes too; then cc, leaving "z".
Constraints
- 0 <= s.length <= 10^5
scontains lowercase English letters
Unlike LC 1047, which removes two equal characters at a time, this removes the whole run.