You are given two strings start and target, both of length n. Each string consists only of the characters 'L', 'R', and '_' where:
'L' and 'R' represent pieces, where a piece 'L' can move to the left only if there is a blank space directly to its left, and a piece 'R' can move to the right only if there is a blank space directly to its right.'_' represents a blank space that can be occupied by any of the 'L' or 'R' pieces.Return true if it is possible to obtain the string target_ by moving the pieces of the string start any number of times_. Otherwise, return false.
Example 1:
Input: start = "L__R__R", target = "L______RR"
Output: true
Explanation: We can obtain the string target from start by doing the following moves:
Example 2:
Input: start = "R_L_", target = "__LR"
Output: false
Explanation: The 'R' piece in the string start can move one step to the right to obtain "RL".
After that, no pieces can move anymore, so it is impossible to obtain the string target from start.
Example 3:
Input: start = "R", target = "R"
Output: false
Explanation: The piece in the string start can move only to the right, so it is impossible to obtain the string target from start.
Constraints:
n == start.length == target.length1 <= n <= 10^5start and target consist of the characters 'L', 'R', and '_'.Need help or want more practice?