// 美好的十月从买卖股票开始
class Solution {
public int maxProfit(int[] prices) {
int maxProfit = 0;
int minPrice = Integer.MAX_VALUE;
for(int i = 0; i<prices.length; i++){
if(prices[i] < minPrice) {
minPrice = prices[i];
} else {
maxProfit = Math.max(prices[i] - minPrice, maxProfit);
}
}
return maxProfit;
}
}