diff --git a/problems/1047.删除字符串中的所有相邻重复项.md b/problems/1047.删除字符串中的所有相邻重复项.md index d5a8c4ed..607a4ccf 100644 --- a/problems/1047.删除字符串中的所有相邻重复项.md +++ b/problems/1047.删除字符串中的所有相邻重复项.md @@ -146,7 +146,17 @@ class Solution { ``` Python: - +```python3 +class Solution: + def removeDuplicates(self, s: str) -> str: + t = list() + for i in s: + if t and t[-1] == i: + t.pop(-1) + else: + t.append(i) + return "".join(t) # 字符串拼接 +``` Go: