Move Pieces To Obtain A String In PHP
Two pointers traverse start and target strings, checking if 'L' moves left and 'R' moves right without crossing each other or changing order.
2337. Move Pieces to Obtain a String Difficulty: Medium Topics: Two Pointers, String You are given two strings start and target, both of length n. Each string consists only of the characters 'L', 'R', and '_' where: The characters '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. The character '_' 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 targe...