C++ | Easiest code | Clean and easy to understand
Please upvote\n\nclass Solution {\npublic:\n    bool canTransform(string s, string e) {\n       int n=s.size(); \n       int i=0,j=0;\n        while(i<n or j<n)
Please upvote\n```\nclass Solution {\npublic:\n    bool canTransform(string s, string e) {\n       int n=s.size(); \n       int i=0,j=0;\n        while(i<n or j<n){\n            \n            while(i<n and s[i]==\'X\'){\n                i++;\n            }\n            while(j<n and e[j]==\'X\'){\n                j++;\n            }\n            if(i==n or j==n){\n                return i==n and j==n;\n            }\n            //no we are at two characters\n            //so now compare\n            if(s[i]!=e[j]){\n                return false;\n            }\n            if(s[i]==e[j] and s[i]==\'R\'){\n                if(j<i){\n                    return false;\n                }\n            }\n            if(s[i]==e[j] and s[i]==\'L\'){\n               if(j>i){\n                   return false;\n               }  \n            }\n            \n            i++;\n            j++;\n        }\n        return true;\n    }\n};\n```
[]