1823. Find the Winner of the Circular Game

Обновлено: 2024-03-12
1 мин
[]

Содержание

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