'L', 'R' and 'X': 'X' is an empty cell, 'L' is a robot that can only drive left, and 'R' is a robot that can only drive right.
In one move, a robot shifts one cell in its direction if that cell is empty. In other words, a piece "XL" may become "LX", and a piece "RX" may become "XR".
Given two strings before and after of the same length, return True if before can be turned into after by some sequence of such moves (possibly none), and False otherwise.before="RXXL", after="XRLX" → True
The R robot moves one cell right and the L robot one cell left: RXXL → XRXL → XRLX.
before="XLR", after="LXR" → True
L slides left into the free cell and R stays where it is.
before="RL", after="LR" → False
Robots cannot pass through each other, so they can never swap places.
before) ≤ 10⁴before) == len(after)'L', 'R' and 'X'before="RXXL", after="XRLX"
True
Run checks the first 3 tests in your browser. Submit checks all 250 tests on the server, hidden ones included.