C++ two pointers O(n)
The key is that we only can make \'L\' backword and \'R\' forward.\n\nclass Solution {\npublic:\n    bool canTransform(string start, string end) {\n        int 
The key is that we only can make \'L\' backword and \'R\' forward.\n```\nclass Solution {\npublic:\n    bool canTransform(string start, string end) {\n        int n = start.size();\n        int i = 0, j = 0;\n        \n        for( ; j < n; j++){\n            if (end[j] == \'X\') continue;\n            \n            while (i < n && start[i] == \'X\') i++;\n            \n            if (i == n) return false;\n            \n            if (end[j] == \'L\'){\n                if (i < j || start[i] != \'L\') return false; //we only can make \'L\' backword\n            }else{\n                if (i > j || start[i] != \'R\') return false; //we only can make \'R\' forward\n            }\n            i++;\n        }\n        \n        while (i < n && start[i] == \'X\') i++;\n        \n        return i == n;\n    }\n};\n```
[]