Skip to content

Commit 7875891

Browse files
add solution 122[js]
1 parent 4c8e808 commit 7875891

File tree

1 file changed

+9
-0
lines changed
  • solution/122.Best Time to Buy and Sell Stock II

1 file changed

+9
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const maxProfit2 = function(prices){
2+
let profit = 0;
3+
for(let i = 1; i < prices.length; i++){
4+
if(prices[i]-prices[i-1] > 0){
5+
profit+=prices[i]-prices[i-1];
6+
}
7+
}
8+
return profit;
9+
}

0 commit comments

Comments
 (0)