Created
December 12, 2020 06:08
-
-
Save Desolve/f7e2c4a352a01676f7dde17345c9f762 to your computer and use it in GitHub Desktop.
1544 Make The String Great
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def makeGood(self, s: str) -> str: | |
if len(s) < 2: return s | |
st = [] | |
for c in s: | |
if st and abs(ord(st[-1]) - ord(c)) == 32: | |
st.pop() | |
else: | |
st.append(c) | |
return ''.join(st) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment