Push Dominoes
Updated
Problem statement
A row of dominoes is described by a string dominoes. An L domino is initially pushed left, an R domino is initially pushed right, and . is upright. Each second, a falling domino pushes its adjacent upright neighbor in its falling direction.
If an upright domino receives equal opposing pushes at the same time, it stays upright. A domino that has already fallen does not change direction. Return the final row after all movement stops.
For this exercise, assume all initial pushes happen at time zero and an empty row is allowed.
Function
pushDominoes(dominoes: String) → StringExamples
Example 1
dominoes = ".L.R...LR..L.."return = "LL.RR.LLRRLL.."Forces spread simultaneously. Equal opposing forces leave the middle upright where they arrive together.
Example 2
dominoes = "RR.L"return = "RR.L"The upright domino receives opposing pushes at the same moment, so it stays upright.
Constraints
- For this exercise, assume
0 <= dominoes.length <= 10000. - Each character is L, R or a period.
More PeopleStrong Onsite Interview questions
- Add Two Binary StringsONSITE INTERVIEW · Seen Mar 2026
- Four SumONSITE INTERVIEW · Seen Mar 2026
- LRU Cache OperationsONSITE INTERVIEW · Seen Mar 2026
- Sliding Window MaximumONSITE INTERVIEW · Seen Mar 2026
- Find the Entry of a Linked List CycleONSITE INTERVIEW · Seen Sep 2025
- Integer to English Words: Up to 20 DigitsONSITE INTERVIEW · Seen Sep 2025
- Word Ladder II: All Shortest TransformationsONSITE INTERVIEW · Seen Sep 2025
- Detect a Cycle in a Linked ListONSITE INTERVIEW · Seen May 2025
- First Nonrepeating CharacterONSITE INTERVIEW · Seen May 2025
- Longest Subarray with a Target SumONSITE INTERVIEW · Seen May 2025
Similar questions at other companies
- Sliding Items on a Circular RingIDFC Bank · ONSITE INTERVIEWIDFC Bank interview questions
- Stateful Log Transform and SearchRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
- Feature Flags with Rules, Dependencies and ExposurePerplexity AI · ONSITE INTERVIEWPerplexity AI interview questions
- Invoice / Payment ReconciliationStripe · PHONE SCREEN · ONSITE INTERVIEWStripe interview questions
- In-Memory Vault File SystemHarvey · ONSITE INTERVIEWHarvey interview questions
- Digit-Coded Card ValidationCapital One · ONSITE INTERVIEWCapital One interview questions
- Query JSON Records with WHERE and ORDER BYGitHub · ONSITE INTERVIEW
- Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
- Generate Word Guess FeedbackAtlassian · ONSITE INTERVIEWAtlassian interview questions
- Route Pattern MatcherGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions