TC: O(1) | SC: O(1) | BEATS 100% | SIMPLEST EXPLANATION
Intuition\n Describe your first thoughts on how to solve this problem. \nIf k is less than n, then simply return the kth child (because ball is passing towards 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIf k is less than n, then simply return the kth child (because ball is passing towards right and it is the first time),\nif k is greater than n, then find the direction of ball pass by dividing k with the total children (n - 1).\nIf the quotient is an odd number that means ball is passing towards left (i.e, in the reverse direction), calculate the remainder and return rem th child from the back of the line (i.e, (n-1) - rem).\nIf the quotient is an even number that means ball is passing towards right (i.e, in the normal direction), calculate the remainder and return rem th child from the start of the line (i.e, rem).\n\n\n# Complexity\n- Time complexity: O(1)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int numberOfChild(int n, int k) {\n        if(k<n){\n            return k;\n        }else{\n            int quo = k / (n - 1);\n            int rem = k % (n - 1);\n            if(quo%2==1){\n                return (n - 1) - rem;\n            }else{\n                return rem;\n            }\n        }\n    }\n}\n```
['Math', 'Java']