✅ Python O(n) solution
\nclass Solution:\n    def maxProfit(self, prices: List[int]) -> int:\n        max_profit = 0\n        min_price = 999999\n        for price in prices:\n       
```\nclass Solution:\n    def maxProfit(self, prices: List[int]) -> int:\n        max_profit = 0\n        min_price = 999999\n        for price in prices:\n            if price < min_price:\n                min_price = price\n            if price - min_price > max_profit:\n                max_profit = price - min_price\n        return max_profit\n```\n\n\tIf you liked it, hit the upvote button! ;)
['Python']