From 658f8674ca6b0f14c151f6c3feb764d20bc7e6e9 Mon Sep 17 00:00:00 2001 From: bumpsoo Date: Mon, 8 Jul 2024 21:44:08 +0900 Subject: [PATCH] https://leetcode.com/problems/find-the-winner-of-the-circular-game --- medium/find_the_winner_of_the_circular_game.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 medium/find_the_winner_of_the_circular_game.py diff --git a/medium/find_the_winner_of_the_circular_game.py b/medium/find_the_winner_of_the_circular_game.py new file mode 100644 index 0000000..7850569 --- /dev/null +++ b/medium/find_the_winner_of_the_circular_game.py @@ -0,0 +1,8 @@ +# https://leetcode.com/problems/find-the-winner-of-the-circular-game + +class Solution: + def findTheWinner(self, n: int, k: int) -> int: + result = 1 + for i in range(2, n + 1): + result = (result + k - 1) % i + 1 + return result