From 102f60b356d7a0bee80e14676f40993568e61c67 Mon Sep 17 00:00:00 2001 From: Deven <63876261+devenperez@users.noreply.github.com> Date: Wed, 26 Nov 2025 20:24:25 -0500 Subject: [PATCH] Time: 3 ms (44.97%), Space: 17.5 MB (99.61%) - LeetHub --- .../1544-make-the-string-great.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/1544-make-the-string-great/1544-make-the-string-great.py b/1544-make-the-string-great/1544-make-the-string-great.py index b4a015a..840d15d 100644 --- a/1544-make-the-string-great/1544-make-the-string-great.py +++ b/1544-make-the-string-great/1544-make-the-string-great.py @@ -3,7 +3,7 @@ class Solution: """ Complexities: Time: O(n) - Space: O(1) + Space: O(n) where n = len(s) """ @@ -12,6 +12,21 @@ class Solution: if len(s) <= 1: return s + + + stack = "" + for letter in s: + stack += letter + + if len(stack) >= 2 and stack[-2] != stack[-1] and stack[-2].lower() == stack[-1].lower(): + stack = stack[:-2] + + return stack + + + + +""" # iterate over all letters # - compare s[i], s[i+1] # - if I remove, look at s[i-1] @@ -26,3 +41,4 @@ class Solution: i += 1 return s +""" \ No newline at end of file