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. laravel框架目录结构详解

  2. Adb logcat 抓日志

    http://blog.csdn.net/hujiachun1234/article/details/43271149 http://www.cnblogs.com/medsonk/p/6344373 ...

  3. Inno Setup界面拉伸

    1.源起: 源于一个安装包的广告定制.广告客服提供的图片太大,inno setup默认尺寸容不下它,需要扩充,拉宽安装界面尺寸. 以inno setup所附带例子说事,其默认尺寸如下: 2.Scale ...

  4. (八) .launch文件 ---编写简单的启动脚本文件

    下面我们将介绍,如何编写一个启动脚本程序:(.launch文件) 还记得我们在 创建ROS软件包教程 中创建的第一个程序包(beginner_tutorials)吗,现在我们要使用它. 在 begin ...

  5. php 图像处理函数

    gd_info       函数:获取当前安装的GD库的信息 getimagesize  函数:获取图像的大小 image_type_to_extension   函数:获取图像类型的文件后缀 ima ...

  6. Employee类

    package demo; import java.time.LocalDate; public class Employee { private String name; private doubl ...

  7. taglib简介

    在 JSP最佳实践的 上一期,您学习了一种基于scriptlet的技术,这种技术被用来将上次修改的时间戳添加到JavaServer Page(JSP)文件中.不幸的是,比起它所提供的短期利益,scri ...

  8. python自学开始

    95年工科女一枚 java工程师算不上,只能说从事java开发相关的工作,由于对Python有着极其浓厚的兴趣,一周时间了解大概之后,决定从今天开始见缝插针自学Python,为了防止本人三天打鱼两天晒 ...

  9. hdu 5326(基础题) work

    http://acm.hdu.edu.cn/showproblem.php?pid=5326 一道水题,题目大意是在公司里,给出n个员工和目标人数m,然后下面的n-1行是表示员工a管理b,问在这些员工 ...

  10. javascript 高级程序设计 五

    1.变量: ECMAScript中的基本类型都是值类型Boolean,Number,Null,Undefined和String,在这里JS和其他的语言有所不同,就是JS中的String是值类型 而不像 ...