Skip to content

Latest commit

 

History

History
16 lines (16 loc) · 325 Bytes

122.md

File metadata and controls

16 lines (16 loc) · 325 Bytes
class Solution {
    public int maxProfit(int[] prices) {
        if(prices.length==0){
            return 0;
        }
       int sum = 0;
        for (int i = 1; i < prices.length; i++) {
        if (prices[i]>prices[i-1]){
           sum+=prices[i]-prices[i-1];
          }
         }
      return sum;
    }
}