Gary Lai
  • Home
  • About
Sign in Subscribe

1544. Make The String Great

Last updated on  Apr 2, 2025

1544. Make The String Great

class Solution:
    def makeGood(self, s: str) -> str:
        
        if len(s) == 0:
            return s
        
        res = []
        
        for c in s:
            if res:
                if res[-1].upper() == c.upper():
                    if (res[-1].isupper() and c.islower()) or (res[-1].islower() and c.isupper()):   
                        res.pop()
                        continue
            res.append(c)
        return ''.join(res)
            
Previous 71. Simplify Path
Next 346. Moving Average from Data Stream
Gary Lai © 2025
  • Sign up
Powered by Ghost