#### 原题说明

In a string composed of `'L'`, `'R'`, and `'X'` characters, like “RXXLRXRXL”, a move consists of either replacing one occurrence of `"XL"` with `"LX"`, or replacing one occurrence of `"RX"` with `"XR"`. Given the starting string start and the ending string end, return True if and only if there exists a sequence of moves to transform one string to the other.

``````Example:
Input: start = "RXXLRXRXL", end = "XRLXXRRLX"
Output: True
Explanation:
We can transform start to end following these steps:
RXXLRXRXL ->
XRXLRXRXL ->
XRLXRXRXL ->
XRLXXRRXL ->
XRLXXRRLX
``````

Note:

1. 1 <= len(start) = len(end) <= 10000.
2. Both start and end will only consist of characters in `{'L', 'R', 'X'}`.

#### 解题思路

• 如果start能变换到end，那么除去两个字符串中的`"X"`，剩余的字符串一定相同。因为任意`"R"``"L"`的相对顺序都不会发生变化，我们定义出去`"X"`的字符串为有效字符串
• 根据变换的规则，`"L"`不能向右移，`“R”`不能向左移，所以 start 中`“L”`对应的 index `"i"` 一定不小于 end 中 `“L”`对应的index `"j"`；start 中`“R”`对应的 index `"i"` 一定不大于 end 中 `“R”`对应的index `"j"`
1. i >= j, 如果 start[i]==end[j]==”L”
2. i <= j, 如果 start[i]==end[j]==”R”

#### 归纳总结

------ 关注公众号：猩猩的乐园 ------