Advertisement
Guest User

Best Time to Buy and Sell Stock II

a guest
Apr 8th, 2020
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.22 KB | None | 0 0
  1. int maxProfit(int* prices, int pricesSize){
  2.     int cnt = 0;
  3.     for(int i = pricesSize - 1; i > 0; i--){
  4.         if(prices[i] > prices[i - 1])
  5.             cnt += prices[i] - prices[i - 1];
  6.     }
  7.    
  8.     return cnt;
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement