任务描述
思路
- 栈实现
实现代码
class Solution:
def removeDuplicates(self, S: str) -> str:
a = [',']
for i in S:
if i==a[-1]:
a.pop()
else:
a.append(i)
return "".join(a[1:])
任务描述
思路
实现代码
class Solution:
def removeDuplicates(self, S: str) -> str:
a = [',']
for i in S:
if i==a[-1]:
a.pop()
else:
a.append(i)
return "".join(a[1:])