O(N) time and O(1) space solution
Intuition\n Describe your first thoughts on how to solve this problem. \nSimilar to valid parentheses\n\nThe rules of a valid are as follow:\n1, L and R does no
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSimilar to valid parentheses\n\nThe rules of a valid are as follow:\n1, L and R does not cross\n2, The index of L in start must not less than the corresponding L in target\n3, The index of R in start must not greater than the corresponding R in target\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\nUsing pointer for each string and check the rules mentioned above\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(N)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n\n# Code\n```\nclass Solution:\n    def canChange(self, start: str, target: str) -> bool:\n        s_p = 0\n        t_p = 0\n\n        while True:\n            while s_p < len(start) and start[s_p] == "_":\n                s_p += 1\n            while t_p < len(target) and target[t_p] == "_":\n                t_p += 1\n            if s_p == len(start) and t_p == len(target):\n                return True\n            if s_p == len(start) or t_p == len(target):\n                return False\n            # if not the same\n            if start[s_p] != target[t_p]: return False\n            # for L \n            if start[s_p] == "L":\n                if s_p < t_p: return False\n            else:\n                if s_p > t_p: return False\n            s_p += 1\n            t_p += 1\n        return \n```
['Python3']