Move Pieces To Obtain String Problem
Move Pieces To Obtain String Problem — ExecCode Medium DSA Practice
Solve the Move Pieces To Obtain String problem on ExecCode. Free online medium DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Given start and target strings made of L, R, and _, decide whether start can become target. L pieces can only move left, R pieces can only move right, and pieces cannot cross each other. Skip blanks with two pointers and compare the real pieces in order.
Examples
Input start = "LRR", target = "L_____RR"; Output true. Input start = "RL", target = "_LR"; Output false
Constraints
1 ≤ n ≤ 10^5
Practice Move Pieces To Obtain String free on ExecCode. Browse DSA problems, topic map, and placement guides.