Skip to content

Instantly share code, notes, and snippets.

@Desolve
Created December 12, 2020 06:08
Show Gist options
  • Save Desolve/f7e2c4a352a01676f7dde17345c9f762 to your computer and use it in GitHub Desktop.
Save Desolve/f7e2c4a352a01676f7dde17345c9f762 to your computer and use it in GitHub Desktop.
1544 Make The String Great
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