imashutosh51

Best Time to buy and sell stock I

Jan 28th, 2026
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.23 KB | None | 0 0
  1. class Solution:
  2.     def maxProfit(self, prices: List[int]) -> int:
  3.         ans=0
  4.         cur_min=prices[0]
  5.         for i in prices:
  6.             cur_min=min(i,cur_min)
  7.             ans=max(ans,i-cur_min)
  8.         return ans
  9.        
Advertisement
Add Comment
Please, Sign In to add comment