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