Given a string S having lowercase English letters, returns a string with no instances of three identical consecutive letters, obtained from S by deleting the minimum possible number of letters.
Example 1
Inputeedaaad
Outputeedaad
Explanation
One occurrence of the letter a is deleted.
Example 2
Inputxxxtxxx
Outputxxtxx
Explanation
Note that the letter x can occur more than three times in the returned string if the occurrences are not consecutive.
Example 3
Inputuuuuxaaaaxum
Outputuuxaaxum