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
Core interview problems are free with a full runner and lessons; Pro opens the complete library.