This commit is contained in:
parent
bd4d2f7f46
commit
94c61a1f83
1 changed files with 10 additions and 0 deletions
10
easy/watter_bottles.py
Normal file
10
easy/watter_bottles.py
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
# https://leetcode.com/problems/water-bottles
|
||||||
|
class Solution:
|
||||||
|
def numWaterBottles(self, numBottles: int, numExchange: int) -> int:
|
||||||
|
ret = numBottles
|
||||||
|
while numBottles >= numExchange:
|
||||||
|
full = numBottles // numExchange
|
||||||
|
ret += full
|
||||||
|
numBottles = (numBottles % numExchange) + full
|
||||||
|
return ret
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue