Java 1 Line simple code 🔥 O(1) Time and space
Intuition\nsince time starts from 0 so K will always be related to n-1.\n\n# Approach\nSo firstly classify watch when ball reverses direction, If the final dire
# Intuition\nsince time starts from ```0``` so `K` will always be related to n-1.\n\n# Approach\nSo firstly classify watch when ball reverses direction, If the final direction is same as the starting direction then it will be like 0 for 1st person, 1 for 2nd person and so on.\nAnd if the direction is reversed then change `K -> K%(n-1)` and return K.\n\n# Complexity\n- Time complexity : O(1)\n\n- Space complexity : O(1)\n\n# Code\n```\nclass Solution {\n    public int numberOfChild(int n, int k) {\n        // for easy understanding subtract n by 1;\n        n--;\n        return (k/n)%2==0 ? k%n : n-k%n;\n        //return (k/(n-1))%2==0 ? k%(n-1) : (n-1)-k%(n-1);\n    }\n}\n```\n\n# Upvote please \n![image.png](https://assets.leetcode.com/users/images/7de4d119-7f40-44d4-b498-8e08dd57ab63_1718574715.7630622.png)\n
['Java']