problem

860. Lemonade Change

solution

class Solution {
public:
bool lemonadeChange(vector<int>& bills) {
int five = , ten = ;
for(auto bill:bills)
{
if(bill==) five++;
else if(bill==) { ten++; five--; }
else if(ten>) { ten--; five--; }
else five -= ;
if(five<) return false;
}
return true;
}
};

参考

1. Leetcode_easy_860. Lemonade Change;

2. Discuss;

3. Grandyang;

05-14 16:08