1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-09-19 17:56:55 +02:00
LeetCode/go/pass-the-pillow.go

11 lines
169 B
Go
Raw Normal View History

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
}