Class Solution
java.lang.Object
g0701_0800.s0777_swap_adjacent_in_lr_string.Solution
777 - Swap Adjacent in LR String.<p>Medium</p>
<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>end</code>, return <code>True</code> if and only if there exists a sequence of moves to transform one string to the other.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> start = “RXXLRXRXL”, end = “XRLXXRRLX”</p>
<p><strong>Output:</strong> true</p>
<p><strong>Explanation:</strong></p>
<pre><code> We can transform start to end following these steps:
RXXLRXRXL ->
XRXLRXRXL ->
XRLXRXRXL ->
XRLXXRRXL ->
XRLXXRRLX
</code></pre>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> start = “X”, end = “L”</p>
<p><strong>Output:</strong> false</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= start.length <= 10<sup>4</sup></code></li>
<li><code>start.length == end.length</code></li>
<li>Both <code>start</code> and <code>end</code> will only consist of characters in <code>'L'</code>, <code>'R'</code>, and <code>'X'</code>.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
canTransform
-