3178. Find the Child Who Has the Ball After K Seconds
IntuitionHard one to solve through optimal solution!ApproachFound internal logic of changing direction!Complexity
Time complexity: O(1)

Space complexity: O(1)
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Hard one to solve through optimal solution!
# Approach
<!-- Describe your approach to solving the problem. -->
Found internal logic of changing direction!
# Complexity
- Time complexity: O(1)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public int numberOfChild(int n, int k) {
        if((k/(n-1))%2==0)
            return k%(n-1);
        return (n-1)-(k%(n-1));
    }
}
```
['Java']