diff options
author | Jack Sangdahl <[email protected]> | 2024-07-06 20:55:22 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2024-07-06 20:55:22 -0600 |
commit | e7289f0016e3004f76759546dbabf1387fa70e65 (patch) | |
tree | 5e3ba1cc6137890aafe395483ff7a1419b9185b0 /water_bottles.py | |
parent | 203c89450fa570f342e23fe4ae9cc0b58dac5140 (diff) | |
download | leetcode-e7289f0016e3004f76759546dbabf1387fa70e65.tar.gz leetcode-e7289f0016e3004f76759546dbabf1387fa70e65.zip |
1518. water bottles
Diffstat (limited to 'water_bottles.py')
-rw-r--r-- | water_bottles.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/water_bottles.py b/water_bottles.py new file mode 100644 index 0000000..0ada9f7 --- /dev/null +++ b/water_bottles.py @@ -0,0 +1,25 @@ +# 1518. Water Bottles + +""" +there are 'numBottles' water bottles that are initially full of water. you +can exchange 'numExchange' empty water botls from the market with one full +water bottle. the operation of drinking a full water bottle turns into an +empty bottle. given the two integers 'numBottles' and 'numExchange', return +the maximum number of water bottles you can drink +""" + + +class Solution(object): + def numWaterBottles(self, numBottles, numExchange): + """ + :type numBottles: int + :type numExchange: int + :rtype: int + """ + return (numBottles * numExchange - 1) // (numExchange - 1) + + +if __name__ == "__main__": + obj = Solution() + print(obj.numWaterBottles(9, 3)) + print(obj.numWaterBottles(15, 4)) |