Tap here to switch tabs
Problem
Submissions

Problem: Maximum Profitable Triplets With Increasing Prices II

Try to solve the Maximum Profitable Triplets With Increasing Prices II problem.

Statement

Given two integer arrays prices and profits of the same length, where prices[i] represents the price of the ithi^{ {th}} item and profits[i] represents the profit of the ithi^{ {th}} item.

Find three indices i, j, and k such that:

  • i<j<ki < j < k

  • prices[i] << prices[j] << prices[k]

Return the maximum possible profit sum profits[i] + profits[j] + profits[k]. If no such triplet exists, return −1-1.

Constraints:

  • 3≤3 \leq prices.length == profits.length ≤50000\leq 50000

  • 1≤1 \leq prices[i] ≤5000\leq 5000

  • 1≤1 \leq profits[i] ≤106\leq 10^6

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Profitable Triplets With Increasing Prices II

Try to solve the Maximum Profitable Triplets With Increasing Prices II problem.

Statement

Given two integer arrays prices and profits of the same length, where prices[i] represents the price of the ithi^{ {th}} item and profits[i] represents the profit of the ithi^{ {th}} item.

Find three indices i, j, and k such that:

  • i<j<ki < j < k

  • prices[i] << prices[j] << prices[k]

Return the maximum possible profit sum profits[i] + profits[j] + profits[k]. If no such triplet exists, return −1-1.

Constraints:

  • 3≤3 \leq prices.length == profits.length ≤50000\leq 50000

  • 1≤1 \leq prices[i] ≤5000\leq 5000

  • 1≤1 \leq profits[i] ≤106\leq 10^6