Remove adjacent, repeated characters in a given string, leaving only one character for each group of such characters.
Examples
“aaaabbbc” is transferred to “abc”
class Solution(object):
def deDup(self, input):
if not input or len(input) < 2:
return input
lst = list(input)
slow,fast = 1,1
while fast < len(lst):
if lst[fast] != lst[slow-1]:
lst[slow] = lst[fast]
slow += 1
fast += 1
return ''.join(lst[:slow])