1518. Water Bottles

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1518

class Solution:
    def numWaterBottles(self, numBottles: int, numExchange: int) -> int:
        res = numBottles
        while numBottles >= numExchange:
            numBottles -= numExchange - 1
            res += 1
        return res