Tag: best time to buy sell stock
-
Data Structures and Algorithms in Java – Arrays – Best time to buy and sell stock
Problem: You are given an array of stock prices with each index of the array representing each day. You need to buy stock one one day and sell it on another subsequent day. What is the maximum profit you can earn? Input: An integer array of prices: prices = [7,1,5,2,6,9] prices[i] denotes the price on…