Back to DSA sheet
Push Dominoes
MediumArraysA row of dominoes is described by 'L' (pushed left), 'R' (pushed right), and '.' (upright). Forces propagate simultaneously; a domino pushed equally from both sides stays upright. Return the final configuration.
Input format (stdin): a single line of L/R/'.'. Output the final state.
Examples
Input: RR.L
Output: RR.L
The R's stop at the L.
Input: .L.R...LR..L..
Output: LL.RR.LLRRLL..
Forces resolve from both directions.
Constraints
- 1 <= length <= 10^5
- characters are 'L', 'R', or '.'
Sheets
NeetCode 250
push-dominoes.cpp3 sample tests
Loading editor
Test results
Run the sample tests to check your solution against expected output.
Custom input (stdin)
Output
Run your code to see its output.