Simple implementation in cpp without any math
IntuitionApproachComplexity

Time complexity:
O(k)


Space complexity:
O(1)

Code
# Intuition


# Approach

# Complexity
- Time complexity:
O(k)

- Space complexity:
O(1)

# Code
```cpp []
class Solution {
public:
    int numberOfChild(int n, int k) {
        bool t=true;
        int i=-1,cnt=-1;
        while(cnt!=k){
             if(i==n-1&&t==true){
            t=!t;
          }
          if(i==0&&t==false){
            t=!t;
          }
          if(t==true){
            i++;
          }
         
          if(t==false){
            i--;
          }
          cnt++;
        }
        return i;
    }
};
```
['C++']