mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
32 lines
1.4 KiB
HTML
32 lines
1.4 KiB
HTML
<p>In a string composed of <code>'L'</code>, <code>'R'</code>, and <code>'X'</code> characters, like <code>"RXXLRXRXL"</code>, a move consists of either replacing one occurrence of <code>"XL"</code> with <code>"LX"</code>, or replacing one occurrence of <code>"RX"</code> with <code>"XR"</code>. Given the starting string <code>start</code> and the ending string <code>result</code>, return <code>True</code> if and only if there exists a sequence of moves to transform <code>start</code> to <code>result</code>.</p>
|
|
|
|
<p> </p>
|
|
<p><strong class="example">Example 1:</strong></p>
|
|
|
|
<pre>
|
|
<strong>Input:</strong> start = "RXXLRXRXL", result = "XRLXXRRLX"
|
|
<strong>Output:</strong> true
|
|
<strong>Explanation:</strong> We can transform start to result following these steps:
|
|
RXXLRXRXL ->
|
|
XRXLRXRXL ->
|
|
XRLXRXRXL ->
|
|
XRLXXRRXL ->
|
|
XRLXXRRLX
|
|
</pre>
|
|
|
|
<p><strong class="example">Example 2:</strong></p>
|
|
|
|
<pre>
|
|
<strong>Input:</strong> start = "X", result = "L"
|
|
<strong>Output:</strong> false
|
|
</pre>
|
|
|
|
<p> </p>
|
|
<p><strong>Constraints:</strong></p>
|
|
|
|
<ul>
|
|
<li><code>1 <= start.length <= 10<sup>4</sup></code></li>
|
|
<li><code>start.length == result.length</code></li>
|
|
<li>Both <code>start</code> and <code>result</code> will only consist of characters in <code>'L'</code>, <code>'R'</code>, and <code>'X'</code>.</li>
|
|
</ul>
|