Search
⌘K

Leetcode 3178. Find the Child Who Has the Ball After K Seconds

Children in a line pass a ball one step per second, reversing direction whenever it reaches either end; determine which child holds the ball after k seconds. Exploit the periodicity 2*(n-1) to reduce k and mirror (reflect) the position past the right end to get the final index.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.