public int allTimeProfit(int arr[]){
        int profit = 0;
        for(int i=1; i < arr.length;i++){
            if(arr[i-1] < arr[i]){
                profit += arr[i] - arr[i-1];
            }
        }
        return profit;
    }
Date 03/04/2016
@author Tushar Roy

Best time to buy and sell stocks.
1) Only 1 transaction is allowed
2) Infinite number transactions are allowed

Time complexity O(n)
Space complexity O(1)

https://leetcode.com/problems/best-time-to-buy-and-sell-stock/
https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/
src/com/interview/array/BuySellStockProfit.java