Backspace String Compare LeetCode solution in Python

1
class Solution:
2
def backspaceCompare(self, s: str, t: str) -> bool:
3
def backwardResult(string):
4
debt = 0
5

6
for c in reversed(string):
7
if c == "#":
8
debt += 1
9

10
elif debt > 0:
11
debt -= 1
12

13
else:
14
yield c
15

16
return all(
17
a == b for (a, b) in zip_longest(backwardResult(s), backwardResult(t))
18
)

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0