Water Bottles Problem

Water Bottles Problem — ExecCode Easy DSA Practice

Solve the Water Bottles problem on ExecCode. Free online easy DSA practice in Math. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given the two integers numBottles and numExchange, return the maximum number of water bottles you can drink. Your task is to there are numBottles water bottles that are initially full of water. You can exchange numExchange empty water bottles from the market with one full water bottle. The operation of drinking a full water bottle turns it into an empty bottle. Return the required answer exactly as shown in the examples.

Examples

Input {"numBottles": 9, "numExchange": 3}; Output 13. Input {"numBottles": 15, "numExchange": 4}; Output 19

Constraints

1 <= numBottles <= 100 2 <= numExchange <= 100

Practice Water Bottles free on ExecCode. Browse DSA problems, topic map, and placement guides.