C++ code, Beats 100%, In O(n) time and O(1) space, Easy to understand
\nclass Solution {\npublic:\n    bool backspaceCompare(string S, string T) {\n        int n1=S.size(),i1=0;\n        int n2=T.size(),i2=0;\n        for(int i=0;
```\nclass Solution {\npublic:\n    bool backspaceCompare(string S, string T) {\n        int n1=S.size(),i1=0;\n        int n2=T.size(),i2=0;\n        for(int i=0;i<n1;i++){\n            if(S[i]==\'#\')\n                i1=i1>1?i1-1:0;\n            else{\n                S[i1]=S[i];\n                i1++;\n            }\n        }\n        for(int i=0;i<n2;i++){\n            if(T[i]==\'#\')\n                i2=i2>1?i2-1:0;\n            else{\n                T[i2]=T[i];\n                i2++;\n            }\n        }\n        if(i1!=i2)\n            return false;\n        for(int i=0;i<i1;i++){\n            if(S[i]!=T[i])\n                return false;\n        }return true;\n    }\n};\n```
[]