100% BEATS || O(1) Complexity || Mathematical Approach
If k is less than n:#\n   - If k is less than the total number of children n, it means the ball won\'t reach either end of the line within k seconds. So, the ch
1. **If `k` is less than `n`:**#\n   - If `k` is less than the total number of children `n`, it means the ball won\'t reach either end of the line within `k` seconds. So, the child who receives the ball after `k` seconds will simply be the `k`th child in the queue.\n\n2. **If `k` is greater than or equal to `n`:**\n   - We imagine the ball moving through the queue in cycles. Each cycle consists of passing the ball from the first child to the last child and vice versa.\n   - We calculate how many complete cycles (`a`) the ball completes and any remaining passes within the current cycle (`b`).\n   - If the number of complete cycles `a` is odd, the direction of passing the ball reverses after each cycle. So, the child who receives the ball after `k` seconds is the child at position `n - 1 - b`.\n   - If the number of complete cycles `a` is even, the direction of passing the ball remains the same after each cycle. So, the child who receives the ball after `k` seconds is the child at position `b`.\n\n# Code\n```\nclass Solution {\npublic:\n    int numberOfChild(int n, int k) {\n        if (k < n)\n            return k;\n        \n        int a = (k / (n - 1));\n        int b = (k % (n - 1));\n        \n        if (a % 2 == 1)\n            return n - 1 - b;\n        return b;\n    }\n};\n```
['Math', 'C++']