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;

【Leetcode_easy】860. Lemonade Change的更多相关文章

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

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

  2. 【LeetCode】518. Coin Change 2 解题报告(Python)

    [LeetCode]518. Coin Change 2 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目 ...

  3. [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 ...

  4. 【转】解决Cannot change version of project facet Dynamic web module to 2.5

    http://blog.csdn.net/steveguoshao/article/details/38414145 我们用Eclipse创建Maven结构的web项目的时候选择了Artifact I ...

  5. 【转】JPA project Change Event Handler / 导致eclipse十分卡

    这是Eclipse中的一个GUG: Bug 386171 - JPA Java Change Event Handler (Waiting) 解决方法: 1.) 退出Myeclipse(或eclips ...

  6. 【笔记】选择框 change 事件获取内容

    还记得之前做过一次js 的联动效果,在获取下拉框change事件后的 value 时,当时的我做得比较费劲. 现在看了高程的表单脚本那一章之后发现有一个更好的方法,那就是直接获取下拉框change 事 ...

  7. 【转】How to Change File Ownership & Groups in Linux

    有关linux下 文件权限的问题,一直不是很清楚.(参考菜鸟教程: http://www.runoob.com/linux/linux-file-attr-permission.html) 像上面这样 ...

  8. 【python】How to change the Jupyter start-up folder

    Copy the Jupyter Notebook launcher from the menu to the desktop. Right click on the new launcher and ...

  9. 【LeetCode】860. 柠檬水找零

    860. 柠檬水找零 知识点:贪心 题目描述 在柠檬水摊上,每一杯柠檬水的售价为 5 美元. 顾客排队购买你的产品,(按账单 bills 支付的顺序)一次购买一杯. 每位顾客只买一杯柠檬水,然后向你付 ...

随机推荐

  1. C# mysql 处理 事务 回滚 提交

    MySqlConnection myCon; void iniMysql() { //连接数据库 myCon = new MySqlConnection("server=127.0.0.1; ...

  2. linux下MySQL的启动与访问

    启动与停止 1.启动 MySQL安装完成后启动文件mysql在/etc/init.d目录下,在需要启动时运行下面命令即可. [root@test1 init.d]# /etc/init.d/mysql ...

  3. 83: 模拟赛 树形dp

    $des$ $sol$ 维护每个点的子树中的信息以及非子树的信息 $code$ #include <bits/stdc++.h> using namespace std; #define ...

  4. 洛谷 P1102 A-B数对 题解

    P1102 A-B 数对 题目描述 出题是一件痛苦的事情! 题目看多了也有审美疲劳,于是我舍弃了大家所熟悉的 A+B Problem,改用 A-B 了哈哈! 好吧,题目是这样的:给出一串数以及一个数字 ...

  5. 33、shuffle性能优化

    一.shuffle性能优化 1.没有开启consolidation机制的性能低下的原理剖析 2.开启consolidation机制之后对磁盘io性能的提升的原理 spark.shuffle.conso ...

  6. PHP is_numeric() 函数

    is_numeric() 函数用于检测变量是否为数字或数字字符串. 例子 <?php $var_name1=; $var_name2="a678"; $var_name3=& ...

  7. bytearray 字符串转为字节

    >>> str="hello world">>> x=bytearray(str)>>> xbytearray(b'hello ...

  8. Codeforces Round #576 (div.1 + div.2)

    Div2 A 长度为\(n(n≤10^5)\)的数组,每个元素不同,求有多少个位置\(d\)满足\(d - x \le j < d \And d < j \le d + y a_d< ...

  9. Failed opening libc!的解决方法

    方法来源: http://www.cfd-online.com/Forums/fluent/135879-setting-process-affinity-failed-opening-libc.ht ...

  10. Language Modeling with Gated Convolutional Networks(句子建模之门控CNN)--模型简介篇

    版权声明:本文为博主原创文章,遵循CC 4.0 by-sa版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/liuchonge/article/deta ...