1823. Find the Winner of the Circular Game

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1823

class Solution:
    def findTheWinner(self, n: int, k: int) -> int:
        if n == 1:
            return 1
        res = (k + self.findTheWinner(n - 1, k)) % n
        return n if res == 0 else res