简单题。注意python的s[:-1]在s == ''时,也是生效的。(返回'')
class Solution: def backspaceCompare(self, S: str, T: str) -> bool: normS = self.normalize(S) normT = self.normalize(T) return normS == normT def normalize(self, s: str) -> str: normStr = '' for char in s: if char == '#': normStr = normStr[:-1] else: normStr += char return normStr