Answer to Question #280488 in Python for saivarun

Question #280488

salary maximum profit

input..1 11 13 21 91


1
Expert's answer
2021-12-17T06:57:21-0500
class MaximumProfitFinder:
    def maximumProfit(self, list, fees):
        def cost(i, n, prev):
            if i >= n:
                return 0
            elif prev == True:
                return max(cost(i+1, n, False) + prices[i] - fees, cost(i + 1, n, prev))
            else:
                return max(cost(i+1, n, True) - prices[i], cost(i + 1, n, prev))
        return cost(0, len(prices), False)
profit = MaximumProfitFinder()
prices = [1, 11, 13, 21, 91]
print(profit.maximumProfit(prices, fees=15))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS