Skip to content

Commit 69a9316

Browse files
committed
python 0860.柠檬水找零 去除无用变量
python 0860.柠檬水找零 去除无用变量:在本题中,20的数量是无用的,因为不需要用来找零,可以不用维护这个变量。
1 parent 9b9a37b commit 69a9316

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

problems/0860.柠檬水找零.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class Solution {
157157
```python
158158
class Solution:
159159
def lemonadeChange(self, bills: List[int]) -> bool:
160-
five, ten, twenty = 0, 0, 0
160+
five, ten = 0, 0
161161
for bill in bills:
162162
if bill == 5:
163163
five += 1
@@ -169,10 +169,8 @@ class Solution:
169169
if ten > 0 and five > 0:
170170
ten -= 1
171171
five -= 1
172-
twenty += 1
173172
elif five > 2:
174173
five -= 3
175-
twenty += 1
176174
else:
177175
return False
178176
return True

0 commit comments

Comments
 (0)