public int maxProfit(int[] prices) {
int min = Integer.MAX_VALUE;
//int max = Integer.MIN_VALUE;
int max = 0;
for (int p: prices) {
min = Math.min(min, p);
max = Math.max(p - min, max);
}
return max;
}
Best Time to Buy and Sell Stock
最新推荐文章于 2018-06-21 19:28:08 发布