Skip to content

Latest commit

 

History

History
40 lines (26 loc) · 877 Bytes

_3178. w contest 401 - q.md

File metadata and controls

40 lines (26 loc) · 877 Bytes

3178. w contest 401 - q1

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : June 08, 2024

Last updated : June 08, 2024


Related Topics : Math, Simulation

Acceptance Rate : 62.369 %


Solutions

Python

# 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