One line Python solution


  • -1
    M

    def maxProfit(self, prices):
    return 0 if len(prices)<2 else max(self.maxProfit(prices[:len(prices)/2]), self.maxProfit(prices[len(prices)/2:]), max(prices[len(prices)/2:])-min(prices[:len(prices)/2]))

    Though not high efficiency.


Log in to reply
 

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