Skip to content

Commit 293aa83

Browse files
committed
best time to buy and sell stock solution apply feedback from minji-go
1 parent eaeb2f9 commit 293aa83

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

best-time-to-buy-and-sell-stock/Yn3-3xh.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@ public int maxProfit(int[] prices) {
1111
int min = prices[0];
1212
int max = 0;
1313
for (int i = 1; i < prices.length; i++) {
14-
if (min > prices[i]) {
15-
min = prices[i];
16-
continue;
17-
}
14+
min = Math.min(min, prices[i]);
1815
max = Math.max(max, prices[i] - min);
1916
}
2017
return max;
2118
}
2219
}
23-

0 commit comments

Comments
 (0)