Skip to content

Commit 7786e33

Browse files
authored
Create Make The String Great.py
1 parent e5f1069 commit 7786e33

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

easy/Make The String Great.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#1544. Make the String Great
2+
class Solution(object):
3+
def makeGood(self, s):
4+
"""
5+
:type s: str
6+
:rtype: str
7+
"""
8+
stk = []
9+
for ch in s:
10+
counter_ch = ch.upper() if ch.islower() else ch.lower()
11+
if stk and stk[-1] == counter_ch:
12+
stk.pop()
13+
else:
14+
stk.append(ch)
15+
return "".join(stk)

0 commit comments

Comments
 (0)