Tap here to switch tabs
Problem
Submissions

Problem: Swap Adjacent in LR String

med
30 min
Try to solve the Swap Adjacent in LR String problem.

Statement

You are given two strings start and result, each composed of the characters 'L', 'R', and 'X'.

A single move consists of performing one of the following operations:

  • Replace any occurrence of "XL" with "LX".

  • Replace any occurrence of "RX" with "XR".

Return true if it is possible to transform start into result through any number of valid moves, or false otherwise.

Constraints:

  • 1≤1 \leq start.length ≤104\leq 10^4

  • start.length ==== result.length

  • Both start and result consist only of the characters 'L', 'R', and 'X'.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Swap Adjacent in LR String

med
30 min
Try to solve the Swap Adjacent in LR String problem.

Statement

You are given two strings start and result, each composed of the characters 'L', 'R', and 'X'.

A single move consists of performing one of the following operations:

  • Replace any occurrence of "XL" with "LX".

  • Replace any occurrence of "RX" with "XR".

Return true if it is possible to transform start into result through any number of valid moves, or false otherwise.

Constraints:

  • 1≤1 \leq start.length ≤104\leq 10^4

  • start.length ==== result.length

  • Both start and result consist only of the characters 'L', 'R', and 'X'.