Skip to content

Practice Push Dominoes

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#838
LeetCode Problem

Push Dominoes

Problem Statement

In dominoes, L and R mark initial pushes left and right, while . marks an upright unpushed domino. All initial pushes happen simultaneously. Each second a falling domino pushes its adjacent upright neighbor in the same direction. Equal-time pushes from both sides balance and leave an upright domino standing. A falling or fallen domino receives no additional force. Return the final L, R and . state string.

Source: Push Dominoes on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

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

# Example 2

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

Constraints

n == dominoes.length
1 <= n <= 10^5
dominoes[i] is either 'L', 'R', or '.'.

Related LeetCode Problems

Practice more problems similar to Push Dominoes.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.