Short Python


  • 0
        def maxProfit(self, prices):
            mn, mx = float("inf"), 0
            for i,v in enumerate(prices):
                mn, mx = min(mn, v), max(mx, v-mn)
            return mx
    

Log in to reply
 

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