-
57. Remove All Adjacent Duplicates in StringProblem Solving 2023. 1. 8. 23:27728x90
https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string/
Remove All Adjacent Duplicates In String - LeetCode
Remove All Adjacent Duplicates In String - You are given a string s consisting of lowercase English letters. A duplicate removal consists of choosing two adjacent and equal letters and removing them. We repeatedly make duplicate removals on s until we no l
leetcode.com
괄호 여닫기 문제와 유사함
class Solution: def removeDuplicates(self, s: str) -> str: now = s[0] for i in s[1:]: if len(now) != 0 and i == now[-1]: now = now[:-1] else: now = now + i return now
긴가민가 했는데 바로 accept 됨
'Problem Solving' 카테고리의 다른 글
60. Height Checker (0) 2023.01.09 58. 소트인사이드 (0) 2023.01.08 56. 스택 (0) 2023.01.08 55. OX 퀴즈 (0) 2023.01.08 54. 다이얼 (0) 2023.01.08