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 70173d7 commit 43e52fcCopy full SHA for 43e52fc
Best Time to Buy and Sell Stock III/code.js
@@ -7,13 +7,11 @@ var maxProfit = function (prices) {
7
let t2Cost = Infinity;
8
let t1Profit = 0;
9
let t2Profit = 0;
10
- for (let i = 0; i < prices.length; i++)
11
- {
+ for (let i = 0; i < prices.length; i++) {
12
t1Cost = Math.min(t1Cost, prices[i]);
13
t1Profit = Math.max(t1Profit, prices[i] - t1Cost);
14
t2Cost = Math.min(t2Cost, prices[i] - t1Profit);
15
t2Profit = Math.max(t2Profit, prices[i] - t2Cost);
16
}
17
return t2Profit;
18
-
19
-}
+};
0 commit comments