A playful "domino" loading animation shows a row of tiles as a string row: "L" is a tile pushed to fall left, "R" a tile pushed to fall right, and "." a standing tile. Every second, each falling tile pushes the standing tile next to it in the same direction. A standing tile pushed from both sides at the same second stays standing. A fallen tile never pushes a tile that has already fallen.
Write settleTiles(row) that returns the row after every tile has stopped moving.
Input: row = "RR.L" Output: "RR.L"
The standing tile is pushed from both sides at the same moment, so it stays.
Input: row = ".L.R...LR..L.." Output: "LL.RR.LLRRLL.."
Each push spreads until it meets another push or a tile falling the other way.
0 <= row.length <= 100000row contains only L, R, and ..Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #598 Settle Falling Tiles. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.