Java || Explained || Easy to understand
// Replace all \'X\' in both strings and see if they are SAME then return true\n// Whenever you see \'X\' just update the idx\n\n// TC : O(N) -> N = start.lengt
// Replace all \'X\' in both strings and see if they are SAME then return true\n// Whenever you see \'X\' just update the idx\n\n// TC : O(N) -> N = start.length\n// SC : O(1)\n```\nclass Solution {\n    public boolean canTransform(String start, String end) {\n        int startIdx = 0;\n        int endIdx = 0;\n        \n        while(startIdx < start.length() || endIdx < end.length()) {\n            while(startIdx < start.length() && start.charAt(startIdx) == \'X\') {\n                startIdx++;\n            }\n            \n            while(endIdx < end.length() && end.charAt(endIdx) == \'X\') {\n                endIdx++;\n            }\n            \n            if(startIdx >= start.length() || endIdx >= end.length()) break; // come out of while loop\n            \n            if(start.charAt(startIdx) != end.charAt(endIdx)) return false;\n            \n            // if the character is \'L\', it can only be moved to the LEFT. startIdx should be greater or equal to endIdx. \n            if(start.charAt(startIdx) == \'L\' && endIdx > startIdx) {\n                return false;\n            }\n            \n            // if the character is \'R\', it can only be moved to the RIGHT. endIdx should be greater or equal to startIdx.\n            if(start.charAt(startIdx) == \'R\' && startIdx > endIdx) {\n                return false;\n            }\n            \n            startIdx++;\n            endIdx++;\n        }\n        \n        return startIdx == endIdx; // if while loop exited because of the string (start or end) reach end but not other, return false\n    }\n}\n```
[]