✅ Easy C++ Solution
Code\n\nclass Solution {\npublic:\n    int numberOfChild(int n, int k) {\n        int curr = 0;\n        bool direction = true;\n        while(k!=0)\n        {\
# Code\n```\nclass Solution {\npublic:\n    int numberOfChild(int n, int k) {\n        int curr = 0;\n        bool direction = true;\n        while(k!=0)\n        {\n            if(direction)\n            {\n                if(curr == n-2)\n                {\n                    direction = false;\n                }\n                curr++;\n            }\n            else if(!direction)\n            {\n                if(curr == 1)\n                {\n                    direction = true;\n                }\n                curr--;\n            }\n            k--;\n        }\n        return curr;\n    }\n};\n```
['C++']