Best Time To Buy And Sell Stock
- Best Time to Buy and Sell Stock
class Solution: def maxProfit(self,prices): left = 0 # Buy right = 1 # Sell max_profit = 0 while right < len(prices): profit = prices[right] - prices[left] # our current profit if prices[left] < prices[right]: max_profit = max(profit,max_profit) else: left = right right += 1 return max_profit