Greedy Python Solution


  • 0
    Y
    def maxProfit(self, prices):
            result = 0
            for i in range(0, len(prices)):
                if i+1 < len(prices):
                    if prices[i+1] >= prices[i]:
                        result += (prices[i+1] - prices[i])
            return result

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.