Skip to content

Commit c05eccc

Browse files
committed
update 121.best-time-to-buy-and-sell-stock.java
1 parent 0c8f109 commit c05eccc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

121.best-time-to-buy-and-sell-stock.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,12 @@ public int maxProfit(int[] prices) {
7777
// ^
7878

7979
int profit = 0;
80-
int buy = Integer.MAX_VALUE;
80+
81+
if (prices.length == 0) {
82+
return profit;
83+
}
84+
85+
int buy = 10000;
8186

8287
for (int i = 0; i < prices.length; i++) {
8388
int curr = prices[i];

0 commit comments

Comments
 (0)