Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @param {number[]} prices
- * @return {number}
- */
- var maxProfit = function(prices) {
- var profit=0;
- for(var i=0;i<prices.length-1;i++)
- {
- if(prices[i]<prices[i+1])
- {
- profit += prices[i+1]-prices[i];
- }
- }
- return profit;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement