C++ | O(1) | Intuition Explained in Detail
After n-1 seconds we reach right end \nAfter next n-1 seconds we reach left end\nAfter next n-1 seconds we right end again \n\n.... and so on \n\nSo,\nif n-1 / 
After n-1 seconds we reach right end \nAfter next n-1 seconds we reach left end\nAfter next n-1 seconds we right end again \n\n.... and so on \n\nSo,\nif `n-1 / k`  is an **odd** number we know for sure we are at **right end**.\n\nif `n-1/ k` is an **even** number then we know for sure we are at **left end.**\n\n\nOnce we figure out which end has the ball , we can use the remaining seconds calculate where the ball will end up .\n\nLets say n=4 , k=14\n\nk/n =>  14/4 => 3\n3 is a odd number so ball is now at right end.\nfrom right end remaining seconds are `remainder` : `k % n` => 14%4 => 2\nso from right end move ball two steps i.e. \n    `n-1 - remainder`\n4-1 - 2 = 1 which is the correct answer .\n\n\n# Code\n```\nclass Solution {\npublic:\n    int numberOfChild(int n, int k) {\n        if(k/(n-1)%2==1){ //odd\n            return n-1- k%(n-1);\n        }\n        else//even\n            return k%(n-1);\n    }\n};\n```
['C++']