Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Divya siddam
code

Divya siddam

Mar 28, 2025

class Solution:

def process(self, s):

    result = []

    for char in s:

        if char == '#':

            if result:

                result.pop()

        else:

            result.append(char)

    return ''.join(result)



def backspaceCompare(self, str1, str2):

    return self.process(str1) == self.process(str2)

0

0

Comments
Comments

On this page