Generation

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/ee292b813ccfe2657c608f782923772d.py", line 37, in <module> print(ob.makeStringEmpty(s)) File "/home/ee292b813ccfe2657c608f782923772d.py", line 18, in makeStringEmpty stack.pop() IndexError: pop from empty list

diff - Expected Output:

Questions about programming?Chat with your personal AI assistant