Movatterモバイル変換


[0]ホーム

URL:


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

Commitad1983b

Browse files
authored
Update 0121-best-time-to-buy-and-sell-stock.java
File Modified: 0121-best-time-to-buy-and-sell-stock.javaLanguage Used: javaSubmission URL:https://leetcode.com/problems/best-time-to-buy-and-sell-stock/submissions/1078835157/Improved readability by moving 'right++' end of 'if' and 'else' block.
1 parent4a57286 commitad1983b

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

‎java/0121-best-time-to-buy-and-sell-stock.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ public int maxProfit(int[] prices) {
77
while (right <prices.length) {
88
if (prices[left] <prices[right]) {
99
maxProfit =Math.max(maxProfit,prices[right] -prices[left]);
10-
right++;
1110
}else {
1211
left =right;
13-
right++;
1412
}
13+
right++;
1514
}
1615
returnmaxProfit;
1716
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp