Skip to content

Commit 43e52fc

Browse files
committed
added New Function
1 parent 70173d7 commit 43e52fc

File tree

1 file changed

+2
-4
lines changed
  • Best Time to Buy and Sell Stock III

1 file changed

+2
-4
lines changed

Best Time to Buy and Sell Stock III/code.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ var maxProfit = function (prices) {
77
let t2Cost = Infinity;
88
let t1Profit = 0;
99
let t2Profit = 0;
10-
for (let i = 0; i < prices.length; i++)
11-
{
10+
for (let i = 0; i < prices.length; i++) {
1211
t1Cost = Math.min(t1Cost, prices[i]);
1312
t1Profit = Math.max(t1Profit, prices[i] - t1Cost);
1413
t2Cost = Math.min(t2Cost, prices[i] - t1Profit);
1514
t2Profit = Math.max(t2Profit, prices[i] - t2Cost);
1615
}
1716
return t2Profit;
18-
19-
}
17+
};

0 commit comments

Comments
 (0)