problem
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;
完