# Best Time to Buy and Sell Stock (Leetcode 121)

Problem Link: <https://leetcode.com/problems/best-time-to-buy-and-sell-stock/>

```python
class Solution:
    def maxProfit(self, prices: List[int]) -> int:
        
        minn=float('inf')
        ans=0
        for i in prices:
            minn=min(minn,i)
            ans=max(ans,i-minn)
        return ans
```
