blob: d1bf6f5b4ad5c3e3d950992e848029f945dd65df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
## strInput = "abbaca" ## Example 1
## strInput = "azxxzy" ## Example 2
## strInput = "aaaaaaaa" ## Example 3
## strInput = "aabccba" ## Example 4
strInput = "abcddcba" ## Example 5
arrOutput = list(strInput)
nIndx = 1
while nIndx < len(arrOutput):
if arrOutput[nIndx] == arrOutput[nIndx - 1]:
arrOutput.pop(nIndx)
arrOutput.pop(nIndx - 1)
nIndx = 1
continue
nIndx = nIndx + 1
print ("".join(arrOutput))
|