Python O(1) Space Two Pointers
Read from tail to head. Use a helper function scan_bs to handle backspace and return the correct idx after backspacing.\nIn each while iteration, if both i and 
Read from tail to head. Use a helper function `scan_bs` to handle backspace and return the correct idx after backspacing.\nIn each while iteration, if both `i` and `j` haven\'t reach the head after `scan_bs`, we compare `S[i] == T[j]`. Until one of pointer reach the head `idx < 0` and break the while loop. Then `S` and `T` are equal only when both two pointers reach the head.\n```\ndef scan_bs(i, s):\n    cnt = 0\n    while i >= 0 and (s[i] == "#" or cnt):\n        cnt += 1 if s[i] == "#" else -1\n        i -= 1\n    return i\n\ndef backspaceCompare(S, T):\n    i, j = scan_bs(len(S)-1, S), scan_bs(len(T)-1, T)\n    while i >= 0 and j >= 0:\n        if S[i] != T[j]:\n            return False\n        i, j = scan_bs(i - 1, S), scan_bs(j - 1, T)\n    return i < 0 and j < 0\n```\n
[]