class Solution {
public:
int maxProfit(vector<int>& prices) {
int res=0;
int minPrice = 2e9;
for(auto price:prices){
minPrice = min(minPrice,price);
res =max(res,price - minPrice);
}
return res;
}
};