class Solution {
public:
    int maxProfit(vector<int>& prices) {

        int profit = 0;
        int min_price = INT_MAX;
        for(int price : prices){
            if(price < min_price){
                min_price = price;
            }else{
                profit = max(profit , price-min_price);
            }
        }

        return profit;
    }
};

https://leetcode.com/problems/best-time-to-buy-and-sell-stock/

https://takeuforward.org/data-structure/stock-buy-and-sell/