classSolution{public:intnumberOfChild(intn,intk){// the time for the ball to return to 0constintroundTime=2*(n-1);constintpos=k%roundTime;returnpos<n?pos:roundTime-pos;}};
12345678
classSolution{publicintnumberOfChild(intn,intk){// the time for the ball to return to 0finalintroundTime=2*(n-1);finalintpos=k%roundTime;returnpos<n?pos:roundTime-pos;}}
123456
classSolution:defnumberOfChild(self,n:int,k:int)->int:# the time for the ball to return to 0roundTime=2*(n-1)pos=k%roundTimereturnposifpos<nelseroundTime-pos