You are given two strings start and target, both of length n. Each string consists exclusively of the characters 'L', 'R', and '_'. The characters 'L' and 'R' represent movable pieces, while '_' represents an empty space.
A piece can move according to the following rules:
A piece 'L' can only move to the left into an adjacent empty space '_'.
A piece 'R' can only move to the right into an adjacent empty space '_'.
Pieces cannot jump over or pass each other.
Return true if it is possible to obtain the string target from start through any number of valid moves. Otherwise, return false.
Constraints:
n start.length target.length
n
start and target consist of the characters 'L', 'R', and '_'.
You are given two strings start and target, both of length n. Each string consists exclusively of the characters 'L', 'R', and '_'. The characters 'L' and 'R' represent movable pieces, while '_' represents an empty space.
A piece can move according to the following rules:
A piece 'L' can only move to the left into an adjacent empty space '_'.
A piece 'R' can only move to the right into an adjacent empty space '_'.
Pieces cannot jump over or pass each other.
Return true if it is possible to obtain the string target from start through any number of valid moves. Otherwise, return false.
Constraints:
n start.length target.length
n
start and target consist of the characters 'L', 'R', and '_'.