class Solution {
public:
int maxProfit(vector<int>& prices) {
int low = INT_MAX, profit = 0;
for (int price : prices) {
low = min(low, price);
profit = max(profit, price - low);
}
return profit;
}
};
REF: