Best Time to Buy and Sell Stock with Transaction Fee

Medium · Dynamic Programming · about 15 minutes

Asked at Meta, Google, Apple, Bloomberg, ByteDance.

prices[i] is the price on day i, and every completed transaction (a buy plus a sell) costs fee. You may trade as often as you like but hold at most one share. Return the maximum profit.

Related guides