Simple O(1) || Solution fast
Complexity\n- Time complexity:\nO(1)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution {\npublic:\n    int numberOfChild(int n, int k) {\n        int tem
# Complexity\n- Time complexity:\n$$O(1)$$\n\n- Space complexity:\n$$O(1)$$\n\n# Code\n```\nclass Solution {\npublic:\n    int numberOfChild(int n, int k) {\n        int temp1 = k / (n - 1);\n        int temp2 = k % (n - 1);\n        if (temp1 % 2 == 0) {\n            // forward\n            return temp2;\n        }\n        // backword\n        return n - 1 - temp2;\n    }\n};\n```
['C++']