Given an array of characters, I need to delete all the characters that got repeated 3 or more times (consecutively) and add '0' at the end of the array for every deleted character,
The restrictions:
- $O(n)$ time
- $O(1)$ memory
- Can't overwrite a cell in the array more than once
Examples: "aacccbbddde" --> "aabbe000000"
I managed to find the following solution without the restriction of $O(1)$ memory / overwrite (I can do only one at a time)
Any ideas?