Back to problems

Move Chess Pieces to Match Target (R moves right, L moves left)

Algorithm · Google · Medium

You are given two strings of identical length, start and target, that describe a one-dimensional board. 'R' denotes a piece permitted to move only to the right. 'L' denotes a piece permitted to move only to the left. '_' represents an unoccupied position. One legal operation exchanges a piece with an immediately neighboring empty position, provided the move follows that piece's direction. For instance, R may become R, while L may become L_. Decide whether applying zero or…

Checking your access…