public int oneProfit(int arr[]){
        int minPrice = arr[0];
        int maxProfit = 0;
        for(int i=1; i < arr.length; i++){
            if(arr[i] - minPrice > maxProfit){
                maxProfit = arr[i] - minPrice;
            }
            if(arr[i] < minPrice){
                minPrice = arr[i];
            }
        }
        return maxProfit;
    }
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