mirror of
https://gitlab.com/mfocko/LeetCode.git
synced 2024-11-09 15:59:06 +01:00
go: add «1823. Find the Winner of the Circular Game»
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
parent
3b9a63195b
commit
a0c53fcdeb
1 changed files with 11 additions and 0 deletions
11
go/find-the-winner-of-the-circular-game.go
Normal file
11
go/find-the-winner-of-the-circular-game.go
Normal file
|
@ -0,0 +1,11 @@
|
|||
package main
|
||||
|
||||
func findTheWinner(n int, k int) int {
|
||||
winner := 0
|
||||
|
||||
for i := 2; i <= n; i++ {
|
||||
winner = (winner + k) % i
|
||||
}
|
||||
|
||||
return winner + 1
|
||||
}
|
Loading…
Reference in a new issue