Leetcode 1128 Solution
This article provides solution to leetcode question 1128 (remove-all-adjacent-duplicates-in-string)
Access this page by simply typing in "lcs 1128" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string
Solution
class Solution:
def removeDuplicates(self, S: str) -> str:
a = []
for s in S:
if a and s == a[-1]:
a.pop(-1)
else:
a.append(s)
return "".join(a)