Open rocksc30 opened 1 year ago
class Solution {
public:
int maxProfit(vector<int>& prices) {
int maxProfit = 0;
int minPirce = INT_MAX;
int len = prices.size();
for(int i = 0 ; i < len ;i++)
{
maxProfit = max(maxProfit , prices[i] - minPirce);
minPirce = min(minPirce,prices[i]);
}
return maxProfit;
}
};