Clean Simple Solution O(1)
Approach\n\nFor n = 5, k = 6\n\n0\t[0, 1, 2, 3, 4]\n1\t[0, 1, 2, 3, 4]\n2\t[0, 1, 2, 3, 4]\n3\t[0, 1, 2, 3, 4]\n4\t[0, 1, 2, 3, 4]\n5\t[0, 1, 2, 3, 4]\n6\t[0, 1
# Approach\n\nFor n = 5, k = 6\n\n0\t[```0```, 1, 2, 3, 4]\n1\t[0, ```1```, 2, 3, 4]\n2\t[0, 1, ```2```, 3, 4]\n3\t[0, 1, 2, ```3```, 4]\n4\t[0, 1, 2, 3, ```4```]\n5\t[0, 1, 2, ```3```, 4]\n6\t[0, 1, ```2```, 3, 4]\n7   [0, ```1```, 2, 3, 4]\n\nFor 8 it again comes to "0"\nand for 9 it comes to "1"\n\nWe should make k between 0 to 8\nSo we mod k with 8 (which is nothing but 2*(n-1))\n\nnow if k is less than n, we return k\nelse we subtract k from 8 (which is nothing but 2*(n-1))\n\nso for 7, 6 and 5 the answers are 1, 2 and 3 respectively\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    def numberOfChild(self, n: int, k: int) -> int:\n\n        k = k % ((n-1)*2)\n        \n        if k < n:\n            return k\n        \n        return (n-1)*2 - k\n```
['Python3']