2907. Maximum Profitable Triplets With Increasing Prices I
Given the 0-indexed arrays
pricesandprofitsof lengthn. There arenitems in an store where theithitem has a price ofprices[i]and a profit ofprofits[i].We have to pick three items with the following condition:
prices[i] < prices[j] < prices[k]wherei < j < k.If we pick items with indices
i,jandksatisfying the above condition, the profit would beprofits[i] + profits[j] + profits[k].Return the maximum profit we can get, and
-1if it’s not possible to pick three items with the given condition.