A Bottle has ml, how many millilitres of water are left in it. Write drink(amount): take a sip, and ml goes down by amount. A sip is never more than what's left.
water_left(500, {100, 50})→350water_left(300, {})→300int water_left(int start, const vector<int> &sips)#include <vector>
using namespace std;
class Bottle {
public:
int ml;
Bottle(int start) {
ml = start;
}
void drink(int amount) {
// your code here: take amount off ml
}
};
int water_left(int start, const vector<int> &sips) {
Bottle b(start);
for (int s : sips) {
b.drink(s);
}
return b.ml;
}
Run tries the examples. When they look right, Submit.