Update 0122.买卖股票的最佳时机II.md

Added python version code
This commit is contained in:
LiangDazhu
2021-05-13 23:27:38 +08:00
committed by GitHub
parent 9d00f80c18
commit 5b6d47dba9

View File

@ -138,7 +138,14 @@ Java
Python Python
```python
class Solution:
def maxProfit(self, prices: List[int]) -> int:
result = 0
for i in range(1, len(prices)):
result += max(prices[i] - prices[i - 1], 0)
return result
```
Go Go