Simulate how a row of dominoes falls after some are initially pushed left or right.
You are given a string representing a row of dominoes. Each character is one domino state:
L means the domino has been pushed to the leftR means the domino has been pushed to the right. means the domino is standing uprightDominoes continue falling in the direction they are pushed. A standing domino will be pushed by a neighboring falling domino if the force reaches it first. If equal force reaches a domino from both sides at the same time, it stays upright.
Return the final state of the row after all dominoes have settled.
dominoes consisting of L, R, and ..dominoes[i] describes the initial state of the i-th domino.1 <= dominoes.length.L, R, and ..Example 1
Input
dominoes = ".L.R...LR..L.."
Output
"LL.RR.LLRRLL.."
Explanation
The pushes propagate through the upright dominoes. Some sections fall left, some right, and some remain upright when forces balance.
Example 2
Input
dominoes = "RR.L"
Output
"RR.L"
Explanation
The two right-pushed dominoes do not affect the left-pushed domino because the standing domino between them blocks the forces from meeting in a way that changes the final state.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.