Skip to content

Commit 95e8873

Browse files
committed
do best time to buy and sell stock 2
1 parent a3b1b89 commit 95e8873

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

my-submissions/m122.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Solution:
2+
def maxProfit(self, prices: List[int]) -> int:
3+
return sum(filter(lambda x: x > 0, [y - x for x, y in zip(prices[:-1], prices[1:])]))

0 commit comments

Comments
 (0)