We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent eebb5f3 commit 723d246Copy full SHA for 723d246
Algorithms/Easy/121_BestTimeToBuyAndSellStock/Solution.c
@@ -2,12 +2,12 @@ int maxProfit(int* prices, int pricesSize){
2
int answer = 0;
3
int buyingPrice = prices[0];
4
5
- for(int i = 1; i < pricesSize; i++){
6
- if(prices[i] < buyingPrice)
+ for (int i = 1; i < pricesSize; i++){
+ if (prices[i] < buyingPrice)
7
buyingPrice = prices[i];
8
else if (prices[i] - buyingPrice > answer)
9
answer = prices[i] - buyingPrice;
10
}
11
12
return answer;
13
-}
+}
0 commit comments