My 1-line python map solution


  • 1
    T
    def maxProfit(self, prices):
        return sum(map(lambda n, pre: max(n - pre, 0), prices[1:], prices[:-1]))

Log in to reply
 

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