My name is Siz. I am a computer science graduate student specializing in backend development with Golang and Python, seeking opportunities in innovative tech projects. My personal website is longsizhuo.com .Connect with me on LinkedIn: https://www.linkedin.com/in/longsizhuo/.
math题,Find a rule,npersonal,interval=n-1,The number of cycles in the crowd= $time // (n-1)$,The number of cycles is2The number of times from scratch,Otherwise, the number of forwards from the back。
Code:
1 2 3 4 5 6 7 8
classSolution: defpassThePillow(self, n: int, time: int) -> int: if n > time: return time + 1 if time // (n-1) % 2 == 0: return time % (n-1) + 1 else: return n - time % (n-1)