Solution
C++ []\nclass Solution {\npublic:\n    bool canTransform(string st, string tar) {\n        int n=tar.length();\n        int i=0,j=0;\n        while(i<=n && j<=n
```C++ []\nclass Solution {\npublic:\n    bool canTransform(string st, string tar) {\n        int n=tar.length();\n        int i=0,j=0;\n        while(i<=n && j<=n){\n            while(i<n && tar[i]==\'X\') i++;\n            while(j<n && st[j]==\'X\') j++;\n            if(i==n || j==n)\n                return i==n && j==n;\n            if(tar[i]!=st[j] || (tar[i]==\'L\' && j<i) || (tar[i]==\'R\' && i<j)) return false;\n            i++,j++;\n        }\n        return true;\n    }\n};\n```\n\n```Python3 []\nclass Solution:\n    def canTransform(self, start: str, end: str) -> bool:\n        countR = countL = 0\n        for i in range(len(start)):\n            if start[i]==\'R\':\n                if countL > 0:\n                    return False\n                countR += 1\n            if end[i]==\'R\':\n                countR -= 1\n                if countR < 0:\n                    return False\n            if end[i]==\'L\':\n                if countR > 0:\n                    return False\n                countL+=1\n            if start[i]==\'L\':\n                countL -= 1\n                if countL < 0:\n                    return False\n        if countR or countL:\n            return False\n        return True \n```\n\n```Java []\nclass Solution {\n    public boolean canTransform(String start, String end) {\n        int i = 0;\n        int j = 0;\n        char[] s = start.toCharArray();\n        char[] e = end.toCharArray();\n        while (i < s.length || j < e.length)\n        {\n            while (i<s.length && s[i] == \'X\') { \n                i++; \n            }\n            while (j<e.length && e[j] == \'X\') {\n                j++; \n            }\n            if (i == s.length || j == e.length) {\n                break; \n            }\n            if (s[i] != e[j] || (s[i] == \'R\' && i > j) || (s[i] == \'L\' && i < j)) {\n                return false; \n            }\n            i++;\n            j++;\n        }\n        return i == j;\n    }\n}\n```\n
['C++', 'Java', 'Python3']