mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 19:44:45 +08:00
Update 0122.买卖股票的最佳时机II.md
Added python version code
This commit is contained in:
@ -138,7 +138,14 @@ Java:
|
||||
|
||||
|
||||
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:
|
||||
|
||||
|
Reference in New Issue
Block a user