Created
May 8, 2020 01:13
-
-
Save ZhouYang1993/2752971ad76d407fcfbaa28ff7b793e3 to your computer and use it in GitHub Desktop.
Algorithms for Interview 1: Stack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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