Algorithm · Amazon · Hard
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 two additional parameters: allowedTransactions – the maximum number of transactions you are permitted. A value of 1…