Iterative Solution | Python
Complexity\n- Time complexity: O(k)\n\n- Space complexity: o(1)\n\n# Code\n\nclass Solution:\n    def numberOfChild(self, n: int, k: int) -> int:\n        child
# Complexity\n- Time complexity: O(k)\n\n- Space complexity: o(1)\n\n# Code\n```\nclass Solution:\n    def numberOfChild(self, n: int, k: int) -> int:\n        child = 0\n        reverse = 0\n        while k:\n            for i in range(n-1):\n                if k==0:\n                    return child\n                child=child+(-1 if reverse else 1)\n                k-=1\n            reverse=(reverse+1)%2\n                \n        return child\n                \n                \n            \n```
['Array', 'Math', 'Python', 'Python3']