BEST-TIME-TO-BUY-AND-SELL-STOCK problem with O(N) solution