5 line CPP solution
\n    int maxProfit(vector& prices) {\n        int maxPro = 0, minPrice = INT_MAX;\n        for(int i = 0; i < prices.size(); i++) {\n            minPrice = min
\n    int maxProfit(vector<int>& prices) {\n        int maxPro = 0, minPrice = INT_MAX;\n        for(int i = 0; i < prices.size(); i++) {\n            minPrice = min(minPrice, prices[i]);\n            maxPro = max(prices[i] - minPrice, maxPro);\n        }\n        return maxPro;\n    }
[]