Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c05eccc

Browse files
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)

AltStyle によって変換されたページ (->オリジナル) /