Python one-liner: beats 93.19% of python submissions.


  • 0
    G
    class Solution(object):
        def maxProfit(self, prices):
            return sum(prices[i]-prices[i-1] for i in xrange(1,len(prices)) if prices[i]>prices[i-1])

Log in to reply
 

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