Tap here to switch tabs
Problem
Submissions

Problem: Push Dominoes

med
30 min
Try to solve the Push Dominoes problem.

Statement

There are nn dominoes placed vertically in a line. You are given a string dominoes of length nn, where each character represents the initial state of a domino:

  • 'L' indicates that the domino is pushed to the left.

  • 'R' indicates that the domino is pushed to the right.

  • '.' indicates that the domino is standing upright and has not been pushed.

At each second, every domino falling to the left pushes the adjacent domino directly to its left, and every domino falling to the right pushes the adjacent domino directly to its right. If an upright domino is pushed from both sides simultaneously, it remains upright due to the balance of forces.

Return a string representing the final state of the dominoes after all movement has ceased.

Constraints:

  • n==n == dominoes.length

  • 1≤n≤1051 \leq n \leq 10^5

  • dominoes[i] is either 'L', 'R', or '.'.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Push Dominoes

med
30 min
Try to solve the Push Dominoes problem.

Statement

There are nn dominoes placed vertically in a line. You are given a string dominoes of length nn, where each character represents the initial state of a domino:

  • 'L' indicates that the domino is pushed to the left.

  • 'R' indicates that the domino is pushed to the right.

  • '.' indicates that the domino is standing upright and has not been pushed.

At each second, every domino falling to the left pushes the adjacent domino directly to its left, and every domino falling to the right pushes the adjacent domino directly to its right. If an upright domino is pushed from both sides simultaneously, it remains upright due to the balance of forces.

Return a string representing the final state of the dominoes after all movement has ceased.

Constraints:

  • n==n == dominoes.length

  • 1≤n≤1051 \leq n \leq 10^5

  • dominoes[i] is either 'L', 'R', or '.'.