葉林
Linked with GitHub
# LeetCode - 0860. Lemonade Change ### 題目網址:https://leetcode.com/problems/lemonade-change/ ###### tags: `LeetCode` `Easy` `模擬` ```cpp= /* -LeetCode format- Problem: 860. Lemonade Change Difficulty: Easy by Inversionpeter */ class Solution { public: bool lemonadeChange(vector<int>& bills) { int counts5 = 0, counts10 = 0; for (int &i : bills) if (i == 5) ++counts5; else if (i == 10) { if (!counts5) return false; --counts5; ++counts10; } else { if (counts10 && counts5) --counts10, --counts5; else if (counts5 >= 3) counts5 -= 3; else return false; } return true; } }; ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up