All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : June 08, 2024
Last updated : June 08, 2024
Related Topics : Math, Simulation
Acceptance Rate : 62.369 %
# https://leetcode.com/problems/find-the-child-who-has-the-ball-after-k-seconds/
# https://leetcode.com/contest/weekly-contest-401/
class Solution:
def numberOfChild(self, n: int, k: int) -> int:
k %= (2 * n - 2)
if k >= n :
return (n - 1) - (k - (n - 1))
return k