Skip to content

Commit 9e72ece

Browse files
committed
122、860提交
1 parent 0fd6bbe commit 9e72ece

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

Week01/122.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Solution:
2+
def maxProfit(self, prices: List[int]) -> int:
3+
profit = 0
4+
for i in range(0, len(prices) - 1):
5+
temp = prices[i + 1] - prices[i]
6+
if temp > 0:
7+
profit = profit + temp
8+
return profit

Week01/860.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# 860. 柠檬水找零
2+
class Solution:
3+
def lemonadeChange(self, bills) -> bool:
4+
five = ten = 0
5+
for money in bills:
6+
if money == 5:
7+
five += 1
8+
elif money == 10:
9+
five -= 1
10+
ten += 1
11+
else:
12+
if ten == 0:
13+
five -= 3
14+
else:
15+
ten -= 1
16+
five -= 1
17+
if five < 0 or ten < 0:
18+
return False
19+
return True
20+

0 commit comments

Comments
 (0)