One line Python solution


  • 0
    Z

    return sum([prices[i+1] - prices[i] if prices[i+1] > prices[i] else 0 for i in xrange(len(prices)-1)])


Log in to reply
 

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