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

17 lines
284 B
Go
Raw Normal View History

package main
func numWaterBottles(numBottles int, numExchange int) int {
drank := 0
for numBottles >= numExchange {
canGet := numBottles / numExchange
drank += canGet * numExchange
numBottles -= canGet * numExchange
numBottles += canGet
}
return drank + numBottles
}