[TypeScript] O(N) time and O(1) space
\nfunction backspaceCompare(s: string, t: string): boolean {\n    let sIndex = s.length - 1;\n    let tIndex = t.length - 1;\n    \n    // Start from end of str
```\nfunction backspaceCompare(s: string, t: string): boolean {\n    let sIndex = s.length - 1;\n    let tIndex = t.length - 1;\n    \n    // Start from end of strings and compare the surviving characters (those that don\'t get backspaced)\n    while (sIndex >= 0 || tIndex >= 0) {\n        \n        // Go to index of next surviving character in s\n        if (s.charAt(sIndex) === \'#\') {\n            let charactersToSkip = 1;\n            while (charactersToSkip >= 0) {\n                sIndex--;\n                if (s.charAt(sIndex) === \'#\')\n                    charactersToSkip++;\n                else\n                    charactersToSkip--;\n            }\n        }\n        \n        // Go to index of next surviving character in t\n        if (t.charAt(tIndex) === \'#\') {\n            let charactersToSkip = 1;\n            while (charactersToSkip >= 0) {\n                tIndex--;\n                if (t.charAt(tIndex) === \'#\')\n                    charactersToSkip++;\n                else\n                    charactersToSkip--;\n            }\n        }\n        \n        // If the surviving characters do not match, the strings are different\n        if (s.charAt(sIndex) !== t.charAt(tIndex)) return false;\n        \n        sIndex--;\n        tIndex--;\n    }\n    return true;\n};\n```
['TypeScript']