public int maxProfit(int[] prices) {
        int diff = 0;
        for(int i=0;i<prices.length-1;i++)
        {
            int local_diff = prices[i+1] - prices[i];
            if(local_diff > 0)
                diff += local_diff;
        }
        return diff;
    }