Skip to content

838. Push Dominoes #1634

Answered by mah-shamim
mah-shamim asked this question in Q&A
May 2, 2025 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

We need to determine the final state of a line of dominoes after they have been pushed by forces from either the left or the right. The key challenge is to efficiently compute the effect of these forces without simulating each second step-by-step, which would be computationally expensive.

Approach

  1. Track Forces from the Right (R):
  • Iterate from left to right to compute the time it takes for each domino to be affected by the nearest 'R' to its left. If a domino is pushed by an 'R', it will start affecting subsequent dominoes until it encounters an 'L', which blocks the force.
  1. Track Forces from the Left (L):
  • Iterate from right to left to compute the time it takes for each domino to be …

Replies: 1 comment 2 replies

Comment options

mah-shamim
May 2, 2025
Maintainer Author

You must be logged in to vote
2 replies
@topugit
Comment options

topugit May 2, 2025
Collaborator

@mah-shamim
Comment options

mah-shamim May 2, 2025
Maintainer Author

Answer selected by topugit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested medium Difficulty
2 participants