✅ O(1) Solution
Solution\nswift\nstruct Solution {\n    @_optimize(speed)\n    func numberOfChild(_ n: Int, _ k: Int) -> Int {\n        let n = n - 1\n        // > Ifthe number
# Solution\n```swift\nstruct Solution {\n    @_optimize(speed)\n    func numberOfChild(_ n: Int, _ k: Int) -> Int {\n        let n = n - 1\n        // > Ifthe number of complete back-and-forth cycles is even:\n        //      -> calculate the remaining passings\n        // > Otherwise (if odd):\n        //      -> the ball is passed backward, so we compute the remaining difference\n        return k / n & 1 == 0 ? k % n : n - k % n\n    }\n}\n```
['Math', 'Swift']