I kept trying to simulate the actual moves, which was a dead end.
First, recognize that pieces cannot cross, so the relative order of pieces must be identical in both configurations. Then, for each piece, verify that it can only move in its allowed direction (L left, R right) and that the target position is reachable without crossing other pieces. This reduces to checking that the i-th piece in start matches the i-th piece in target, and that L pieces don't move right and R pieces don't move left.
Pro tip: Mention that this problem is equivalent to checking if the start configuration can be transformed into the target by sliding pieces, which is a common interview question at Google. Emphasize the importance of edge cases like empty boards or boards with only one type of piece.
Extract the sequence of pieces (ignoring dots) from both start and target. If they differ, return false immediately because pieces cannot cross.
For each corresponding piece, ensure that L pieces in start are at positions >= their positions in target (since they move left), and R pieces are at positions <= their positions in target (since they move right).
Consider cases where there are no pieces, or where pieces are already in the correct position. Also, ensure that the lengths of start and target are equal.
Write a function that iterates through both strings simultaneously, skipping dots, and applies the checks. Test with provided examples and additional edge cases.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.