Created
December 3, 2018 18:01
-
-
Save farsialgorithm/05601640e018b5a6b4dd7ab2496ca985 to your computer and use it in GitHub Desktop.
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
| 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