Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[pull] master from youngyangyang04:master #277

New issue

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

Merged
pull merged 20 commits into AlgorithmAndLeetCode:master from youngyangyang04:master
Jun 2, 2023
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
38503dd
Update 1049.最后一块石头的重量II.md about rust
fwqaaq May 12, 2023
db21086
Update 0494.目标和.md about rust
fwqaaq May 12, 2023
03829cd
Apply suggestions from code review
fwqaaq May 12, 2023
1ed8111
新增 ```Java 以正常顯示保留字顏色
Lozakaka May 15, 2023
4948ef4
新增java解法中 lambda以及linkedlist.add的註釋
Lozakaka May 17, 2023
d988722
Update 0053.最大子序和.md
jianghongcheng Jun 1, 2023
d65f7a3
Update 0045.跳跃游戏II.md
jianghongcheng Jun 1, 2023
440bddb
Update 1005.K次取反后最大化的数组和.md
jianghongcheng Jun 1, 2023
648b0d2
Update 0134.加油站.md
jianghongcheng Jun 1, 2023
cfb10d2
Update 0135.分发糖果.md
jianghongcheng Jun 1, 2023
ba3c7ec
Update 0860.柠檬水找零.md
jianghongcheng Jun 1, 2023
cd4d546
Update 0435.无重叠区间.md
jianghongcheng Jun 1, 2023
458f94b
Update 0763.划分字母区间.md
jianghongcheng Jun 1, 2023
352b51d
Update 0056.合并区间.md
jianghongcheng Jun 1, 2023
41dd31d
Update 0738.单调递增的数字.md
jianghongcheng Jun 1, 2023
9b7bedf
Merge pull request #2116 from jianghongcheng/master
youngyangyang04 Jun 1, 2023
bf2d349
Merge pull request #2085 from fwqaaq/patch-42
youngyangyang04 Jun 1, 2023
6156804
Merge pull request #2086 from fwqaaq/patch-43
youngyangyang04 Jun 1, 2023
80cb527
Merge pull request #2091 from Lozakaka/patch-13
youngyangyang04 Jun 2, 2023
4ab224b
Merge pull request #2089 from Lozakaka/patch-12
youngyangyang04 Jun 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update 0860.柠檬水找零.md
  • Loading branch information
jianghongcheng authored Jun 1, 2023
commit ba3c7ec19b6b2ad3f95f35ae55f25b2459d710b3
31 changes: 23 additions & 8 deletions problems/0860.柠檬水找零.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -164,24 +164,39 @@ class Solution {
```python
class Solution:
def lemonadeChange(self, bills: List[int]) -> bool:
five, ten = 0, 0
five = 0
ten = 0
twenty = 0

for bill in bills:
# 情况一:收到5美元
if bill == 5:
five += 1
elif bill == 10:
if five < 1: return False
five -= 1

# 情况二:收到10美元
if bill == 10:
if five <= 0:
return False
ten += 1
else:
if ten > 0 and five > 0:
ten -= 1
five -= 1

# 情况三:收到20美元
if bill == 20:
# 先尝试使用10美元和5美元找零
if five > 0 and ten > 0:
five -= 1
elif five > 2:
ten -= 1
#twenty += 1
# 如果无法使用10美元找零,则尝试使用三张5美元找零
elif five >= 3:
five -= 3
#twenty += 1
else:
return False

return True


```

### Go
Expand Down

AltStyle によって変換されたページ (->オリジナル) /