DNPotapov / Codewars-katas-

0 stars 0 forks source link

122. Best Time to Buy and Sell Stock II (Замена каты на leetcode) #36

Open DNPotapov opened 1 year ago

DNPotapov commented 1 year ago
class Solution:
    def maxProfit(self, prices: List[int]) -> int:
        res = 0
        for i in range(1,len(prices)):
            if prices[i] > prices[i-1]:
                res += prices[i] - prices[i-1]

        return res
DNPotapov commented 1 year ago

https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/