visited of size n to keep track of friends who have received the ball.visited[0] to true since the first friend starts with the ball.currentPosition to 0 and passCount to 1.currentPosition has not been visited:
a. Mark the friend at currentPosition as visited.
b. Calculate the next position using (currentPosition + (passCount * k)) % n.
c. Increment passCount.losers to store the indices of the friends who never received the ball.visited array and for each false value, add the index + 1 to the losers array.losers array.