FORMULA BASED FULL EXPLAINATION
IntuitionFor n students from 0 to n-1 , then from last to 1st notice a cycle !Hence ball goes in cycle be just get the effective shift in its initial Pos and de
# Intuition
For n students from 0 to n-1 , then from last to 1st notice a cycle !

Hence ball goes in cycle be just get the effective shift in its initial Pos and determine its Directions of motion either` L TO R `or `R TO L` .
# Approach
- Total cyclic shifts 0 to n-1 and back to 0th 
(Take is as n vertices and n-1 edges to connect)
L to R : n-1 shifts/edges
R to L : n-1 shifts/edges
Hence `totalShifts = 2*(n-1) shifts 
`
- `Effective pos `(take % of k as it give how many times balls shifts ) = `k%(totalShifts)`

- Now Direction : 
    1)  `effPos from 0 to n-1 : L to R`
    2)  `effPos from n-1 to 2*(n-1) : R to L`

L to R . Effective pos give the children left on rightSide
R to L . totalShifts - Effective pos give the children on LeftSide

# Complexity
- Time complexity: O(1)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public int numberOfChild(int n, int k) {
        int shifts = 2*(n-1) ;
        int effPos = k%(shifts);
        if ( effPos < n-1){// towards Right
            return effPos;
        }else {
            return shifts - effPos;
        }
        
    }
}
```
['Java']