Skip to content

Instantly share code, notes, and snippets.

@farsialgorithm
Created December 3, 2018 18:01
Show Gist options
  • Select an option

  • Save farsialgorithm/05601640e018b5a6b4dd7ab2496ca985 to your computer and use it in GitHub Desktop.

Select an option

Save farsialgorithm/05601640e018b5a6b4dd7ab2496ca985 to your computer and use it in GitHub Desktop.
def backspaceCompare( S, T):
def normalize(s):
stack = []
for c in s):
if c!='#':
stack.append(c)
elif stack:
stack.pop()
return "".join(stack)
return normalize(list(S)) == normalize(list(T))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment