Easy to follow C++ solution
We just need to record each \'L\' and \'R\' positions in both string, and compare them. Since \'L\' can only move left and \'R\' can only move right,  \'L\' pos
We just need to record each \'L\' and \'R\' positions in both string, and compare them. Since \'L\' can only move left and \'R\' can only move right,  \'L\' position in end string should be <= that in start string. Similarly \'R\' position in end string should be >= that in start string.\n\n```\nclass Solution {\npublic:\n    bool canTransform(string start, string end) {\n        std::vector<std::pair<char, int>> pos1, pos2;\n        for (int i = 0; i < start.size(); ++i) {\n            if (start[i] != \'X\') {\n                pos1.push_back(std::make_pair(start[i], i));\n            }\n            if (end[i] != \'X\') {\n                pos2.push_back(std::make_pair(end[i], i));\n            }\n        }\n        \n        if (pos1.size() != pos2.size()) {\n            return false;\n        }\n        \n        for (int i = 0; i < pos1.size(); ++i) {\n            if (pos1[i].first != pos2[i].first) {\n                return false;\n            }\n            \n            if (pos1[i].first == \'L\' && pos1[i].second < pos2[i].second) {\n                return false;\n            }\n            \n            if (pos1[i].first == \'R\' && pos1[i].second > pos2[i].second) {\n                return false;\n            }\n        }\n    \n        return true;\n    }\n};\n```
[]