Trains the technique from
LeetCode 838Push DominoesThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A row of tiles stands on edge and reads tiles. Each character is 'L' for a tile pushed leftwards at the same instant, 'R' for one pushed rightwards, and '.' for one left standing.
A falling tile pushes the standing tile beside it in the same direction, which then falls too, and so on. A standing tile pushed from both sides at the same instant stays standing. A tile already fallen is unaffected by anything that reaches it later.
Return the row once everything has settled.
Example 1
The pushed tile topples everything to its right, one after another. The two standing tiles to its left have nothing pushing them at all.
Example 2
The middle tile is reached from both sides at the same instant, so it stays standing.
Example 3
The leftward push at the front has nothing behind it to topple. The two standing tiles between the pushes are pushed apart rather than together, so neither falls. The rightward push topples everything after it.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def push_dominoes(tiles: str) -> str:public String pushDominoes(String tiles)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.