mirror of
https://gitlab.com/mfocko/LeetCode.git
synced 2024-11-10 00:09:06 +01:00
12 lines
147 B
Go
12 lines
147 B
Go
|
package main
|
||
|
|
||
|
func findTheWinner(n int, k int) int {
|
||
|
winner := 0
|
||
|
|
||
|
for i := 2; i <= n; i++ {
|
||
|
winner = (winner + k) % i
|
||
|
}
|
||
|
|
||
|
return winner + 1
|
||
|
}
|