Falling Dominoes
Dominoes stand in a row. At the start row[i] is L if domino i is pushed to the left, R if it is pushed to the right, and . if it is left standing.
Every second, each domino that is falling to the left knocks over the standing domino on its left, and each domino falling to the right knocks over the standing one on its right. A standing domino that is hit from both sides in the same second stays standing for good. A domino that is already falling is never changed.
Return the row when nothing moves any more, written with the same three characters.
Example 1
The R knocks over the two dominoes after it, the L the one before it. The domino in the middle is hit from both sides at once.
Example 2
The first domino falls left onto nothing, and the R pushes over everything to its right.
Constraints
1 <= len(row) <= 100- every character is
L,Ror.
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Strings problems
- Fit the Capital PatternMedium
- Kth Letter of the Unpacked TextMedium
- Solve for xMedium
- String to IntegerMedium
- Substrings With Every VowelMedium
- Undo the Column ReadMedium
- Valid Decimal LiteralMedium
- Zigzag ConversionMedium