当前位置:网站首页>860. 柠檬水找零
860. 柠檬水找零
2022-06-09 14:10:00 【anieoo】
原题链接:860. 柠檬水找零

solution:
贪心策略:店家找零钱的时候有先使用面值较大的.
class Solution {
public:
bool lemonadeChange(vector<int>& bills) {
int five = 0,ten = 0; //5元和10元的数量
for(auto &x : bills) {
if(x == 5) five++;
else if(x == 10) ten++,five--;
else if(ten > 0 && x == 20) ten--,five--;
else five -= 3;
if(five < 0) return false;
}
return true;
}
};边栏推荐
- 今天19:30 | 图形学专场—中国科学院计算技术研究所高林老师团队
- 我为InfoQ写作社区定制一款机械键盘庆生
- Multivariate time series analysis -- causal test
- 5年没发论文,读博想放弃?中科大博导万字自述:曾连收13封拒稿信...
- IDEA复制方法的全路径
- Google installs the impression note clipping plug-in
- Qiniu cloud backup website
- 中国加密艺术师孟晓峰参加意大利举办的“液态合金”元宇宙画展
- Introduction to assembly language - instruction and addressing
- C language -- greedy method
猜你喜欢

Hardware foundation - analog circuit

数据科学中的 10 个重要概念和图表的含义

C# ListBox用法

CICC digital intelligence China II: five questions and five answers to database business market

unity Dots的IComponent使用的列表踩的坑

分布式限流之基于Sentinel实现的限流漫谈(一)-概述

From just entering the testing industry to doubling my salary: talk about my advanced testing experience, which is worth learning from

GreatSQL如何做中国广受欢迎的开源数据库

MySQL数据库的日志管理

鸿蒙移植i.mx6ull(五) 移植概述
随机推荐
为什么 SQL 语句使用了索引,但却还是慢查询?
鸿蒙移植i.mx6ull(九) 串口移植(基于IMX6ULL)
QUIC会成为互联网传输的颠覆者吗?
Implementation scheme of RTSP video stream real-time playing on web end of webcam
文字广播图的错误代码
mysql学习
IDEA复制方法的全路径
Is it reliable and safe to open an account for external futures?
unity Dots的IComponent使用的列表踩的坑
C # calculate two time intervals
Nerf neural radiation field eccv2020
单元测试概述
Award winning research
Tailwind 导致 antd 的 button icon 不居中的 bug
Hongmeng transplantation i.mx6ull (V) overview of transplantation
外盘期货开户,可靠安全吗?
知名网络安全硬件平台厂商铵泰克加入龙蜥社区
喜报 | 旺链科技签约汨罗市文旅体产业项目,打造“链”上数字乡村
临时全局变量和IRISTEMP数据库
数据科学中的 10 个重要概念和图表的含义