2337. Move Pieces to Obtain a String

Practice Move Pieces to Obtain a String for free on NudgeCode: Medium, Two Pointers pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

start and target have the same length and consist of 'L', 'R' and '_' (a blank). An 'L' piece can move one step left into a blank; an 'R' piece can move one step right into a blank. Pieces cannot jump over each other. Return true if target can be reached from start with any number of moves.

Example

start = "_L__R__R_", target = "L______RR"  ->  true
start = "R_L_",      target = "__LR"       ->  false
start = "_R",        target = "R_"         ->  false

Constraints