Skip to content

#714 - Best Time to Buy and Sell Stock with Transaction Fee

MediumDP - Multidimensional
Open on LeetCode

Given an array prices where prices[i] is the stock price on day i, and an integer fee for each transaction (buy + sell = one transaction), find the maximum profit. You may complete as many transactions as you like, but you must sell before buying again.

InputOutput
prices = [1,3,2,8,4,9], fee = 28
prices = [1,3,7,5,10,3], fee = 36

Released under the MIT License.