[C++] Two pointers solution [Detailed Explanation]
\n/*\n    https://leetcode.com/problems/swap-adjacent-in-lr-string/\n    \n    Things to note:\n    1. Based on the swap patterns, L can be moved to left in pre
```\n/*\n    https://leetcode.com/problems/swap-adjacent-in-lr-string/\n    \n    Things to note:\n    1. Based on the swap patterns, L can be moved to left in presence of X\n    2. R can be moved right in presence of X\n    \n    So that means it is only possible to swap and reach end iff each L in start lies atleast\n    >= position compared to end and each R in start should be <= position compared to end.\n    This is again due to the fact that L can only move left and R can move right.\n    \n    So we start traversal ignoring the X and focus on the breaking cases, if we don\'t find any breaking cases\n    then it is possible.\n    TC: O(N)\n    SC: O(1)\n*/\nclass Solution {\npublic:\n    bool twoPointerSol(string start, string end) {\n        // both the strings have be of same size\n        if(start.size() != end.size())\n            return false;\n        \n        int n = start.size();\n        int i = 0, j = 0;\n        \n        while(i < n && j < n) {\n            // Get past all the X since these help move L or R\n            while(i < n && start[i] == \'X\')\n                ++i;\n            while(j < n && end[j] == \'X\')\n                ++j;\n            \n            // traversal finished, so it must be possible\n            if(i == n && j == n)\n                return true;\n            \n            // if the curr char is not same, then there is no way to match \n            if(start[i] != end[j])\n                return false;\n            \n            // If both point to R, then start\'s ptr should be <= end\'s ptr since\n            // R can move towards right\n            if(start[i] == \'R\' && i > j)\n                return false;\n            \n            // If both point to L, then start\'s ptr should be >= end\'s ptr since\n            // L can move towards left\n            if(start[i] == \'L\' && i < j)\n                return false;\n            ++i, ++j;\n        }\n        \n        // We might still have some chars left for one of the strings\n        // Eg start = XXXXL, end = XLXXX \n        // \'i\' will end first. So let the indices get past X and then check if they both finished processing\n        while(i < n && start[i] == \'X\')\n            ++i;\n        while(j < n && end[j] == \'X\')\n            ++j;\n\n        return i == j;\n    }\n    \n    bool canTransform(string start, string end) {\n        return twoPointerSol(start, end);\n    }\n};\n```
['C', 'C++']