본문 바로가기

IT/코딩테스트

[Leetcode] 1544. Make The String Great

728x90

https://leetcode.com/problems/make-the-string-great

class Solution:
    def makeGood(self, s: str) -> str:
        stack = []
        for c in s:
            if stack and abs(ord(c) - ord(stack[-1])) == 32 :
                stack.pop()
            else:
                stack.append(c)

        return ''.join(stack)
728x90