Beats 94.43% in runtime & 63% in memory  Only 6 lines !!!!!
\n\n\n\nPlease UPVOTE \n\n\n\n# Code\n\nclass Solution(object):\n    def maxProfit(self, prices):\n        l,r=0,1;maxP=0 \n        while r<len(prices):\n      
![image.png](https://assets.leetcode.com/users/images/298dc630-31a5-4e65-b0eb-cf5bfdb3bc3e_1691325811.8985078.png)\n\n\n\nPlease UPVOTE \n\n\n\n# Code\n```\nclass Solution(object):\n    def maxProfit(self, prices):\n        l,r=0,1;maxP=0 \n        while r<len(prices):\n            if prices[l]<prices[r]:profit=prices[r]-prices[l];maxP=max(maxP, profit)                \n            else:l=r \n            r+=1\n        return maxP\n\n```
['Python3']