Practice Swap Adjacent in LR String
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
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 result, return True if and only if there exists a sequence of moves to transform start to result.
Source: Swap Adjacent in LR String on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
start = "RXXLRXRXL", result = "XRLXXRRLX"
true
# Example 2
start = "X", result = "L"
false
Constraints
Related LeetCode Problems
Practice more problems similar to Swap Adjacent in LR String.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.