Simple Python code
class Solution(object):\n        def maxProfit(self, prices):\n            """\n            :type prices: List[int]\n            :rtype: int\n            """\n 
    class Solution(object):\n        def maxProfit(self, prices):\n            """\n            :type prices: List[int]\n            :rtype: int\n            """\n            n=len(prices)\n            if n<=1:\n                return 0\n            max_profit=0\n            low_price=prices[0]\n            for i in range(1,n):\n                low_price=min(low_price,prices[i])\n                max_profit=max(max_profit, prices[i]-low_price)\n            return max_profit
[]