Back to course home
0% completed
Vote For New Content
Maximum Profitable Triplets With Increasing Prices I (medium)
Problem Statement
You are given two 0-indexed arrays, prices and profits, both of length n. There are n items in an store where the i<sup>th</sup> item has a price of prices[i] and a profit of profits[i].
You have to select three items with the following condition:
prices[i] < prices[j] < prices[k]wherei < j < k.- If such a selection is possible, calculate the total profit, which is
profits[i] + profits[j] + profits[k].
Return the maximum possible profit from this selection. If it's not possible to select three items that satisfy these conditions, return -1
.....
.....
.....
Like the course? Get enrolled and start learning!