simple C++ O(N) Stack Solution beats 90%
\nclass Solution {\npublic:\n    bool canTransform(string start, string end) {\n        stack<pair<char, int>> st1, st2;\n        if (start.length() != end.leng
```\nclass Solution {\npublic:\n    bool canTransform(string start, string end) {\n        stack<pair<char, int>> st1, st2;\n        if (start.length() != end.length()) return false;\n        for (int i = 0; i < start.length(); i++) {\n            if (start[i] != \'X\')    st1.push(make_pair(start[i], i));\n            if (end[i] != \'X\')  st2.push(make_pair(end[i], i));\n        }\n        if (st1.size() != st2.size())   return false;\n        while (!st1.empty()) {\n            char ch1 = st1.top().first, ch2 = st2.top().first;\n            int pos1 = st1.top().second, pos2 = st2.top().second;\n            st1.pop();\n            st2.pop();\n            if (ch1 != ch2) return false;\n            if (ch1 == \'R\') {\n                if (pos1 > pos2)   return false;    \n            } else {\n                if (pos1 < pos2)   return false;\n            }\n        }\n        \n        return true;\n    }\n};\n```
[]