Medium · Strings
Swap Adjacent in LR String
Given two equal-length strings start and target made of 'L', 'R' and 'X', where one move replaces an occurrence of "XL" with "LX" or of "RX" with "XR", return true if some sequence of moves turns start into target, otherwise false.
Examples
Example 1
{
"start": "RXXLRXRXL",
"target": "XRLXXRRLX"
}Output: true
Example 2
{
"start": "XL",
"target": "LX"
}Output: true
Rebuild it in the studio
Open every published interview problem, solution, scene, and memory room free, with no account.