1823. Find the Winner of the Circular Game

Question

CleanShot 2024-10-31 at 21.57.40.png

Code

class Solution:
    def findTheWinner(self, n: int, k: int) -> int:
        
        # shift all numbers by -k posistions
        def winner(n, k):
            if n == 1:
                return 0
            return (winner(n - 1, k) + k) % n

        return winner(n, k) - 1