Skip to content

Commit 290b09c

Browse files
committed
working commit - Created using LeetHub
1 parent 8051dce commit 290b09c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

water-bottles/water-bottles.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution {
2+
public:
3+
   int numWaterBottles(int numBottles, int numExchange) {
4+
       int a = numBottles;
5+
       int b = 0;
6+
       int k = numExchange;
7+
       
8+
       int ans = 0;
9+
       while(a != 0){
10+
           ans += a;
11+
           
12+
           b = b + a;
13+
           a = b/k;
14+
           b = b%k;
15+
      }
16+
       
17+
       return ans;
18+
  }
19+
};

0 commit comments

Comments
 (0)