fix invalid codeThu, 23 Mar 2023

def makeStringEmpty(self, s: str) -> int: count = 0 stack = [] for char in s: if not stack or char != 'k' or stack[-1] != 'e' or (len(stack) > 1 and stack[-2] != 'e'): stack.append(char) else: stack.pop() stack.pop() stack.pop() count += 1 if not stack: return count else: return -1 our Output: Traceback (most recent call last): File "/home/", line 37, in <module> print(ob.makeStringEmpty(s)) File "/home/", line 18, in makeStringEmpty stack.pop() IndexError: pop from empty list

diff - Expected Output:

Questions about programming?Chat with your personal AI assistant