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

扫描一遍,问题不大

860. Lemonade Change的更多相关文章

  1. 【Leetcode_easy】860. Lemonade Change

    problem 860. Lemonade Change solution class Solution { public: bool lemonadeChange(vector<int> ...

  2. [LeetCode&Python] Problem 860. Lemonade Change

    At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you, and ...

  3. 【LeetCode】860. Lemonade Change 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...

  4. [LeetCode] Lemonade Change 买柠檬找零

    At a lemonade stand, each lemonade costs $5.  Customers are standing in a queue to buy from you, and ...

  5. [Swift]LeetCode860. 柠檬水找零 | Lemonade Change

    At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you, and ...

  6. LeetCode-860. Lemonade Change

    At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you, and ...

  7. [LeetCode] 860. Lemonade Change_Easy tag: Greedy

    At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you, and ...

  8. LeetCode – Lemonade Change

    At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you, and ...

  9. C#LeetCode刷题之#860-柠檬水找零(Lemonade Change)

    问题 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/4036 访问. 在柠檬水摊上,每一杯柠檬水的售价为 5 美元. 顾 ...

随机推荐

  1. 颜色 color

    在res/values文件夹下的color.xml添加 <?xml version="1.0" encoding="utf-8"?> <res ...

  2. Angular之RouterModule的forRoot与forChild

    Angular 提供了一种方式来把服务提供商从模块中分离出来,以便模块既可以带着 providers 被根模块导入,也可以不带 providers 被子模块导入. 区别: `forRoot` crea ...

  3. HDU 3251 Being a Hero(最小割+输出割边)

    Problem DescriptionYou are the hero who saved your country. As promised, the king will give you some ...

  4. Gradle 实战(1)—— 配置环境变量

    背景:Gradle 是一款构建工具,继 Ant .Maven 之后的现代构建工具,我会在接下来的博文中陆续介绍,我在工作中是如何使用 Gradle 的. 下载 Gradle 下面是 Gradle 的官 ...

  5. FOR ALL ENTRIES的使用

    使用FOR ALL ENTRIES时注意: 1.一定要确定要有是否为空的判断 2.一定要注明两个表之间数据的关系 eg: IF GT_TJ30T[] IS NOT INITIAL.      SELE ...

  6. Excel上传找到错误数据类型

    一:查询数据库表中字段的类型语句 SELECT CASE WHEN col.colorder = 1 THEN obj.name ELSE '' END AS 表名, col.colorder AS ...

  7. Jmeter分布测试

    一.负载机为Linux Linux上安装Jmeter 1.Windows中jmeter整个安装目录copy至Linux /usr/local/autodeploy目录 ps.使用winSCP工具cop ...

  8. visual studio 2017 30天到期,不能输入注册码

    官网下载了visual studio 2017后,第一次安装没有登陆,导致只有30天试用期,虽然还在试用期内,但是无法使用注册码永久使用 解决办法: 1.注册一个微软账号,直接百度搜索“微软账号登陆” ...

  9. Android.Zygote

    Zygote进程 http://www.kaifazhe.com/android_school/397261.html http://anatomyofandroid.com/2013/10/15/z ...

  10. Git和SourceTree入门教程

    转自CSDN:http://blog.csdn.net/collonn/article/details/39259227 -->本教程适用于主流的开源网站github和bitbucket,个人认 ...