1
0
Fork 0
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:
Matej Focko 2024-07-08 13:52:37 +02:00
parent 3b9a63195b
commit a0c53fcdeb
Signed by: mfocko
SSH key fingerprint: SHA256:5YXD7WbPuK60gxnG6DjAwJiS9+swoWj33/HFu8g8JVo

View 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
}