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. PHP中的变量与PHP中算false的情况

    一PHP中的变量 1.PHP中的变量,声明与使用必须用$开头 2.PHP是一种弱类型语言,变量其实并不需要声明.可以直接给变量赋任何类型的值: 3.PHP中可以使用连等同时声明多个变量, eg:num ...

  2. redis 简介,安装与部署

    NOSQL简介 NoSQL,泛指非关系型的数据库,NoSQL数据库的四大分类: 键值(Key-Value)存储数据库:这一类数据库主要会使用到一个哈希表,这个表中有一个特定的键和一个指针指向特定的数据 ...

  3. queue模拟

    BlockingQueue:顾名思义,首先它是一个队列,并且支持阻塞的机制,阻塞的放入和得到数据.我们要实现LinkedBlockingQueue下面两个简单的方法put和take. put(anOb ...

  4. gitbook的学习

    gitbook安装与使用之windows下搭建gitbook平台 最近需要在GitBook中去阅读电子书 安装nodejs cnpm安装gitbook 解压书籍文件,并cd到书籍文件目录 gitboo ...

  5. PTA 7-6 列出连通集(深搜+广搜)

    给定一个有N个顶点和E条边的无向图,请用DFS和BFS分别列出其所有的连通集.假设顶点从0到N−1编号.进行搜索时,假设我们总是从编号最小的顶点出发,按编号递增的顺序访问邻接点. 输入格式: 输入第1 ...

  6. [Java学习]面向对象-多态

    多态 多态发生条件 发生在有继承关系的类型中. 向上转型(自动类型转换)与向下转型(强制类型转换) //向上转型 //编译阶段a1被编译器看作是Animal类型,所以a1引用绑定的是Animal类中的 ...

  7. python + selenium 学习笔记 -摘要

    一.浏览器操作相关 from selenium import webdriver driver = webdriver.Chrome() driver.maximize_window() # 窗口最大 ...

  8. xcode 更新svn/Git后发现模拟器显示No Scheme问题

    这个是由于XXX..xcodeproj包中xcuserdata文件夹中user.xcuserdatad文件夹名字的问题...user.xcuserdatad文件夹的名字,不是当前用户的名字,就会显示n ...

  9. swift - 本地通知

    1. AppDelegate  注册 class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? fun ...

  10. spring boot项目打包成war并在tomcat上运行的步骤

    把spring-boot项目按照平常的web项目一样发布到tomcat容器下 一.修改打包形式 在pom.xml里设置 <packaging>war</packaging> 二 ...