title: Using Python to update min and max values while iterating over a list
body: <p>I'm working on this problem. My code is below.</p>
  
  <pre><code>class Solution(object):
      def maxProfit(self, prices):
          """
          :type prices: List[int]
          :rtype: int
          """
  
          min_stock = 1000000
          max_profit = 0
  
          for i in range(len(prices)):
              if prices[i] &lt; min_stock:
                  min_stock = prices[i]
  
              if prices[i] - min_stock &gt; max_profit:
                  max_profit = prices[i] - min_stock
  
          return max_profit
  </code></pre>
  
  <p>For the input [7,1,5,3,6,4] this is returning 0, which I can't figure why to save my life. Wouldn't min be updated eventually to be 1, and then max_profit would be updated to be 6 - min = 6 - 1 = 5?</p>