Throw The Ball
Asked at Flexport · Coding Questions · Difficulty: Medium · Last asked Jul 15, 2026
In a park, there are `n` friends standing in a random order, and they plan to throw a ball around. Each friend has a unique number in the range of 1 to `n`, inclusive. The `i`^th friend will always throw the ball towards the friend given at `receiver[i]`, and this will happen each second. Friend 1 always starts with the ball, and a player always throws to another player. Determine which friend has the ball after `k` seconds pass.
Loading the problem…