We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
原题链接
这道题的场景和几年前的我们现实生活中很像,毕竟 2021 年的现在大家都用手机支付了,不过也刚好怀旧一波。
先明确,题目要求我们一开始是没有钱的,全靠老天爷赏饭吃。江山父老能容我 不使人间造孽钱
江山父老能容我 不使人间造孽钱
所以,分为 3 种情况来进行分析:
const lemonadeChange = function(bills) { let five = 0, ten = 0 const len = bills.length for (let i = 0; i < len; i++) { if (bills[i] == 5) { five++ } else if (bills[i] == 10) { if (five == 0) { return false } five-- ten++ } else if (bills[i] == 20) { if (ten > 0 && five > 0) { ten-- five-- } else if (five >= 3) { five -= 3 } else { return false } } } return true }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
原题链接
贪心
这道题的场景和几年前的我们现实生活中很像,毕竟 2021 年的现在大家都用手机支付了,不过也刚好怀旧一波。
先明确,题目要求我们一开始是没有钱的,全靠老天爷赏饭吃。
江山父老能容我 不使人间造孽钱
所以,分为 3 种情况来进行分析:
The text was updated successfully, but these errors were encountered: