Description

Given a string representing dominoes pushed left 'L', right 'R', or standing '.', return final state.

Examples

Input:dominoes = ".L.R...LR..L.."
Output:"LL.RR.LLRRLL.."
Explanation:

Simulate domino falls.

Input:dominoes = "a"
Output:"LL.RR.LLRRLL.."
Explanation:

Edge case with a single character.

Input:dominoes = "RR.L"
Output:RR.L
Explanation:

The first two dominoes are already pushed right. The rightmost domino is pushed left but there's a gap (standstill domino) between the R and L forces, so they don't interact. The middle domino remains upright as it's equidistant from both forces, creating a stable equilibrium point.

Constraints

  • 1 ≤ dominoes.length ≤ 10⁵

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!