Leetcode 777. Swap Adjacent in LR String
Given two strings of 'L', 'R', and 'X', determine if start can be transformed into result by repeatedly applying moves "XL" → "LX" (L moves left) and "RX" → "XR" (R moves right). This reduces to verifying the L/R order (ignoring X) is the same and that every L in start is not left of its target and every R in start is not right of its target.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Late July, 2026
Imagine you are given a gameboard with 2 pieces "L" and "R". L can move left and R can move right. But they cannot cross each other. Given a start game board with pieces in different position and a end game board with pieces in different positions. Tell if end board is valid. Example 1: Start: _ L _ R _ R_ _ End: L _ _ R _ _ R Ans: Valid Example 2: Start: _ _ R End: _R _ Ans: Invalid ( R cannot move left) Example 3: Start: _ R _ L _ End: _ _ _ R L
Hello Interview Premium
Your account is free and you can post anonymously if you choose.