121:买卖股票的最佳时机

This commit is contained in:
huangge1199@hotmail.com 2021-04-15 23:11:20 +08:00
parent 73df49ad3d
commit 7fecd74df0

View File

@ -52,6 +52,7 @@ public class BestTimeToBuyAndSellStock {
for (int i = 1; i < prices.length; i++) {
if (prices[i] > min) {
max = Math.max(max, prices[i] - min);
continue;
}
min = Math.min(min, prices[i]);
}