Revert Approach Solution 
IntuitionI was thinking that how can i revert when i reach either of the end then i got this approach.Approach -> Revert ApproachComplexity
Time complexity: O(K
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nI was thinking that how can i revert when i reach either of the end then i got this approach.\n# Approach -> Revert Approach\n<!-- Describe your approach to solving the problem. -->\n\n\n# Complexity\n- Time complexity: O(K)\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```java []\nclass Solution {\n    public int numberOfChild(int n, int k) {\n        int pointer = 0;\n        boolean revert = false;\n        for(int i=0;i<=k;i++){\n            if(i>0){\n                if(!revert){\n                    pointer = pointer + 1;\n                    if(pointer == n-1){\n                        revert = true;\n                    }\n                }else{\n                    pointer = pointer - 1;\n                    if(pointer == 0){\n                        revert = false;\n                    }\n                }\n            }            \n        }\n        return pointer;\n    }\n}\n```
['Java']