Algorithm · Amazon · Hard
Best Time to Buy and Sell Stock with Custom Constraints Medium · Array, Dynamic Programming, Greedy · Company Tags · Hints You are given an array prices recording the daily price of a stock. On each day you may choose to buy one share or sell one share, but you can hold at most one share at any moment (you must sell before you can buy again). A complete buy‑and‑sell pair counts as one transaction. Your goal is to maximize the total profit. The trading rules are governed by…
Checking your access…