Practice Maximize Value of Function in a Ball Passing Game
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Hard#2836
LeetCode ProblemMaximize Value of Function in a Ball Passing Game
Problem Statement
Player i passes the ball to receiver[i], which may be i itself. Choose any starting player and make exactly k passes. The score is the sum of the indices of the starting player and every receiver of a pass, counting repeated visits again. Return the greatest possible score.
Source: Maximize Value of Function in a Ball Passing Game on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
receiver = [2,0,1], k = 4
Output
6
# Example 2
Input
receiver = [1,1,1,2,3], k = 3
Output
10
Constraints
1 <= receiver.length == n <= 10^5
0 <= receiver[i] <= n - 1
1 <= k <= 10^10
Related LeetCode Problems
Practice more problems similar to Maximize Value of Function in a Ball Passing Game.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.