easy python 2 solution, pass test


  • 0
    Y

    my code passes all test and I think it is very intuitive.
    '''

    def maxProfit(prices):

    ls=[]
    min = prices[0]
    for price in prices:
        if price < min:
            min=price
        if price >= min:
            ls.append(price-min)
    return max(ls)
    

    '''


Log in to reply
 

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