This commit is contained in:
parent
94c61a1f83
commit
658f8674ca
1 changed files with 8 additions and 0 deletions
8
medium/find_the_winner_of_the_circular_game.py
Normal file
8
medium/find_the_winner_of_the_circular_game.py
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue