Python 3 -> Very simple solution. Explanation added
Suggestions to make it better are always welcomed.\n\nWe might think about using sliding window technique, but obviously we don\'t need subarray here. We just n
**Suggestions to make it better are always welcomed.**\n\nWe might think about using sliding window technique, but obviously we don\'t need subarray here. We just need one value from the given input list. So, this technique is not useful.\n\n**Solution:**\nWe always need to know what is the maxProfit we can make if we sell the stock on i-th day. So, keep track of maxProfit.\nThere might be a scenario where if stock bought on i-th day is minimum and we sell it on (i + k)th day. So, keep track of minPurchase as well.\n\n```\ndef maxProfit(self, prices: List[int]) -> int:\n\tif not prices:\n\t\treturn 0\n\n\tmaxProfit = 0\n\tminPurchase = prices[0]\n\tfor i in range(1, len(prices)):\t\t\n\t\tmaxProfit = max(maxProfit, prices[i] - minPurchase)\n\t\tminPurchase = min(minPurchase, prices[i])\n\treturn maxProfit\n```\n\n**I hope that you\'ve found this useful.\nIn that case, please upvote. It only motivates me to write more such posts\uD83D\uDE03**
['Python', 'Python3']