Easy C++ O(n) solution with explanation
NOTE:\n - In the given string start, L can move to the left but can\'t pass through R, R can move to the right but can\'t pass through L. Basically, there are 4
NOTE:\n - In the given string `start`, `L` can move to the left but can\'t pass through `R`, `R` can move to the right but can\'t pass through `L`. Basically, there are 4 situations (when `start[i] != \'X\'` and `end[j] != \'X\'`):\n   - `start[i] != end[j]` return `false`, cause `L` and `R` can\'t pass through each other.\n   - `start[i] == \'L\' && j > i ` return `false`, cause `L` can\'t move to the right.\n   - `start[i] == \'R\' && j < i` return `false` cause `R` can\'t move to the left.\n\n```\nclass Solution {\npublic:\n    bool canTransform(string start, string end) {\n        int i = 0, j = 0;\n        for (; i < start.size() && j < end.size();) {\n            if (start[i] == \'X\') i++;\n            if (end[j] == \'X\') j++;\n            \n            if (start[i] != \'X\' && end[j] != \'X\') {\n                if (start[i] != end[j]) return false;\n                else if (start[i] == \'L\' && j > i) return false;\n                else if (start[i] == \'R\' && j < i) return false;\n                else i++, j++;\n            }\n        }\n        \n        while (i < start.size()) {\n            if (start[i++] != \'X\') return false;\n        }\n        \n        while (j < end.size()) {\n            if (end[j++] != \'X\') return false;\n        }\n        \n        return true;\n    }\n};\n```
[]