121:买卖股票的最佳时机
This commit is contained in:
parent
73df49ad3d
commit
7fecd74df0
@ -52,6 +52,7 @@ public class BestTimeToBuyAndSellStock {
|
|||||||
for (int i = 1; i < prices.length; i++) {
|
for (int i = 1; i < prices.length; i++) {
|
||||||
if (prices[i] > min) {
|
if (prices[i] > min) {
|
||||||
max = Math.max(max, prices[i] - min);
|
max = Math.max(max, prices[i] - min);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
min = Math.min(min, prices[i]);
|
min = Math.min(min, prices[i]);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user