Skip to content

Instantly share code, notes, and snippets.

@EfrainReyes
Last active November 8, 2022 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EfrainReyes/d7a59e9dc3bac323c56d46bb934f25f3 to your computer and use it in GitHub Desktop.
Save EfrainReyes/d7a59e9dc3bac323c56d46bb934f25f3 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) <= 1:
return s
stack = []
for char in s:
if (stack and stack[-1] != char
and stack[-1].lower() == char.lower()):
stack.pop()
else:
stack.append(char)
return "".join(stack)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment