mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 19:44:45 +08:00
添加 1047.删除字符串中的所有相邻重复项
This commit is contained in:
@ -146,7 +146,17 @@ class Solution {
|
|||||||
```
|
```
|
||||||
|
|
||||||
Python:
|
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:
|
Go:
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user