###########################################################################
#                                                                         #
# Author: Daniel Mock                                                     #
#                                                                         #
# Purpose: To document progress in learning algorithms & data structures  #
#                                                                         #
# References: This question was generated by leetcode.com. The solution   #
# to the question was generated by Daniel Mock.                           #
#                                                                         #
###########################################################################
"A little faster method"
import math
class Solution:
    def maxProfit(self, prices: List[int]) -> int:
        min_i = math.inf
        max_profit = 0
        for index, i in enumerate(prices[:-1]):
            if i < min_i:
                min_i = i
                max_i = max(prices[index+1:])
                if max_i - min_i > max_profit:
                    max_profit = max_i-min_i
        return max_profit

" 'Time Limit Exceeded', brute force method"
'''
class Solution:
    def maxProfit(self, prices: List[int]) -> int:
        max_profit = 0
        for index, i in enumerate(prices[:-1]):
            for index2, ii in enumerate(prices[index+1:]):
                if ii - i > max_profit:
                    max_profit = ii - i
        return max_profit
'''
