LeetCode/go/pass-the-pillow.go
Matej Focko e4dbf828e0
go: add «2582. Pass the Pillow»
Signed-off-by: Matej Focko <me@mfocko.xyz>
2024-07-06 11:05:16 +02:00

10 lines
169 B
Go

package main
func passThePillow(n int, time int) int {
rounds, leftover := time/(n-1), time%(n-1)
if rounds%2 == 0 {
return leftover + 1
}
return n - leftover
}