My python code beats 75% submissions


  • 0
    C
    def maxProfit(self, prices):
        """
        :type prices: List[int]
        :rtype: int
        """
        
        profit = [0]
        for i in range(len(prices)-1):
            if prices[i+1]-prices[i]>0:
                profit.append(prices[i+1]-prices[i])
            
        return sum(profit)

Log in to reply
 

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