algorithms.tutorialhorizon.com
Stock Single Sell Problem - Java Implementation | Algorithms
Given an array represents cost of a stock on each day. You are allowed to buy and sell the stock only once. Write an algorithm to maximize the profit in single buy and sell. Exam­ple: int[] prices = {200, 500, 1000, 700, 30, 400, 900, 400, 50}; Output: Maximum Profit: 870, buy date index: 4, sell date index: 6