Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ZhouYang1993/2752971ad76d407fcfbaa28ff7b793e3 to your computer and use it in GitHub Desktop.
Save ZhouYang1993/2752971ad76d407fcfbaa28ff7b793e3 to your computer and use it in GitHub Desktop.
Algorithms for Interview 1: Stack
class Solution:
def backspaceCompare(self, S: str, T: str) -> bool:
def get_stack(string: str):
stack = []
for s in string:
if s != '#':
stack.append(s)
else:
if stack:
stack.pop()
return stack
return get_stack(S) == get_stack(T)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment