首页 > TAG信息列表 > Lemonade
leetcode算法题--Lemonade Change
原题链接:https://leetcode.com/problems/lemonade-change/ bool lemonadeChange(vector<int>& bills) { int tens = 0, fives = 0; for (auto x : bills) { if (x == 5) { fives ++ ; } else if (x == 10) { if (five【数据结构】算法 Lemonade Change 柠檬水零钱
目录Lemonade Change 任务调度器思路tag Lemonade Change 任务调度器 At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you, and order one at a time (in the order specified by bills). Each customer will only buy one lemonad860. Lemonade Change [Easy]
贪婪问题,每一次找钱都要让自己手中留下尽可能多的5r // 这题很简单,不涉及算法,按正常逻辑写就行,Runtime: 1 ms, faster than 100.00% class Solution { public boolean lemonadeChange(int[] bills) { if (bills[0] != 5) return false; int five = 0, ten