Algorithm · Amazon · Hard
Solve each of the following three independent coding problems. For every solution, state the worst-case time and space complexity, justify correctness, and discuss relevant corner cases. Part 1: Best single stock trade. You are given an integer array prices of length n, where prices[i] is the stock price on day i. You may make at most one purchase and one later sale. Return a list [maxProfit, buyDay, sellDay] such that 0 4 -> 3 -> 6. Example 3: Explanation: The first two…
Checking your access…