https://leetcode.com/problems/best-time-to-buy-and-sell-stock/
class Solution {
public:
int maxProfit(vector<int>& prices) {
if (prices.size()<2)
return 0;
int minv=prices[0];
int profit=0;
for (int i=0;i<prices.size();i++)
{
if (prices[i]<minv)
{
minv=prices[i];
}
if ((prices[i]-minv)>profit)
{
profit=(prices[i]-minv);
}
}
return profit;
}
};