Move Pieces to Obtain a String

Medium · Greedy · about 20 minutes

Asked at Google, Amazon, Microsoft.

Strings start and target contain 'L', 'R' and '_' (blank). An 'L' can move left into a blank and an 'R' right into a blank, any number of times; pieces can't pass each other. Return true if start can become target.

Related guides