1234567891011121314151617181920212223 |
- # There is a better way to do this, try think a little more.
- # Perhaps compare a char at a time? Need to be able to extend until the end of the string though.
-
- class Solution:
- def backspaceCompare(self, S: str, T: str) -> bool:
- resS = ""
- for c in S:
- if c != '#':
- resS += c
- elif len(resS) > 0:
- resS = resS[0:len(resS) - 1]
- resT = ""
- for c in T:
- if c != '#':
- resT += c
- elif len(resT) > 0:
- resT = resT[0:len(resT) - 1]
-
- return resS == resT
-
- s = Solution()
- print("Expected: True")
- print("Got:", s.backspaceCompare("xywrrmp", "xywrrmu#p"))
|