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
'IT > 코딩테스트' 카테고리의 다른 글
[Leetcode] 1700. Number of Students Unable to Eat Lunch (0) | 2024.04.08 |
---|---|
[Leetcode] 678. Valid Parenthesis String (0) | 2024.04.07 |
[Leetcode] 938. Range Sum of BST (0) | 2024.04.05 |
[Leetcode] 205. Isomorphic Strings (0) | 2024.04.02 |
[Leetcode] 58. Length of Last Word (1) | 2024.04.01 |