[Python] Check their positions - with Picture - Clean & Concise
Key observations:\n- There are three kinds of characters, L, R, X.\n- Replacing XL with LX = move L to the left by one.\n- Replacing RX with XR = move R to the 
**Key observations:**\n- There are three kinds of characters, `L`, `R`, `X`.\n- Replacing `XL` with `LX` = move `L` to the left by one.\n- Replacing `RX` with `XR` = move `R` to the right by one.\n- If we remove all the `X` in both strings, the resulting strings should be the same.\n\n**Additional observations:**\n- Since a move always involves `X`, an `L` or `R` cannot move through another `L` or `R`.\n- Since an `L` can only move to the right, for each occurrence of `L` in the start string, its position should be to the same or to the left of its corresponding `L` in the end string.\n\n![image](https://assets.leetcode.com/users/images/d3a2cefe-6cd4-49fa-ad7c-f825369e753c_1635008908.8039162.png)\n\n\n```python\nclass Solution:\n    def canTransform(self, start: str, end: str) -> bool:\n        # L, R orders must be the same\n        if start.replace("X", "") != end.replace("X", ""):\n            return False\n        \n        n = len(start)\n        startL = [i for i in range(n) if start[i] == \'L\']\n        endL = [i for i in range(n) if end[i] == \'L\']\n        startR = [i for i in range(n) if start[i] == \'R\']\n        endR = [i for i in range(n) if end[i] == \'R\']\n        \n        for i, j in zip(startL, endL):\n            if i < j:\n                return False\n            \n        for i, j in zip(startR, endR):\n            if i > j:\n                return False\n        \n        return True\n```\nComplexity:\n- Time: `O(N)`, where `N <= 10^4` is length of `start` or `end` string.\n- Space: `O(N)`\n\nNote: This post is written based on this **[Easy-to-understand explanation with PICTURE](https://leetcode.com/problems/swap-adjacent-in-lr-string/discuss/873004/Easy-to-understand-explanation-with-PICTURE)** post.
[]