[C++] Simple subsequence matching with position constraint.
We see that L can move backwards and R can move forwards. So we can first see if subsequence that contains only L & R is the same for start and end. If so, we c
We see that L can move backwards and R can move forwards. So we can first see if subsequence that contains only L & R is the same for start and end. If so, we can compare the corresponding positions of L and R. \nFor L in start it need to be somewhere ahead of corresponding L in end (since L can only move backwards).\nFor R in start, it needs to be somewhere behind of corresponding R in end.\n\n```\n    bool canTransform(string start, string end) {\n        int n=start.size();\n        assert(n == end.size());\n\t// --Check for anagrams.\n        int lcnt = 0, rcnt = 0;\n        for(int i=0;i<n;i++){\n            if(start[i] == \'L\') ++lcnt;\n            else if(start[i] == \'R\') ++rcnt;\n            if(end[i] == \'L\') --lcnt;\n            else if(end[i] == \'R\') --rcnt;\n        }\n        if(lcnt || rcnt) return false;\n        \n        int i=0,j=0;\n        while(j < n && i < n){\n            while(j < n && end[j] == \'X\') ++j;\n            while(i < n && start[i] == \'X\') ++i;\n            if(i==n&&j==n) break;\n            if(i==n || j==n || start[i] != end[j]) return false;\n            if(start[i] == \'R\' && i > j) return false;\n            else if(start[i] == \'L\' && i < j) return false;\n            ++i; ++j;\n        }\n        \n        return true;\n    }\n```
[]