0%

LeetCode-1047

题目

结果

代码

1
2
3
4
5
6
7
8
9
10
11
func removeDuplicates(S string) string {
stk := make([]rune, 0)
for _, v := range S {
if len(stk) != 0 && stk[len(stk)-1] == v {
stk = stk[:len(stk)-1]
} else {
stk = append(stk, v)
}
}
return string(stk)
}