Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. /**
  2. * @param {number[]} prices
  3. * @return {number}
  4. */
  5. var maxProfit = function(prices) {
  6. var profit=0;
  7. for(var i=0;i<prices.length-1;i++)
  8. {
  9. if(prices[i]<prices[i+1])
  10. {
  11. profit += prices[i+1]-prices[i];
  12.  
  13. }
  14. }
  15. return profit;
  16. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement