#3178
Find the Child Who Has the Ball After K Seconds
pupil · 365 · lc easy +23 · 62.1% accepted · 180 likes · top 63%
Description
There are n children (0 to n - 1) in a line. Child 0 starts with a ball moving right; each second the ball advances one position, reversing direction at the endpoints. Return the index of the child holding the ball after k seconds.
Code
1
2
3