FastPrepMaximum Profit from an Increasing Price Triplet
Problems/Maximum Profit from an Increasing Price Triplet

Maximum Profit from an Increasing Price Triplet

Odoo logoOdoo● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamples

Problem statement

Source note: Reported in an Odoo online assessment for a full-time role. The report leaves out the number limits. We added them.

Our version is about 98% the same as the reported question.

An analyst observes a stock over n days. The stock price on day i is price[i], and the profit associated with that day is profit[i].

Choose three indices i < j < k such that price[i] < price[j] < price[k]. Return the maximum possible value of profit[i] + profit[j] + profit[k]. If no valid triplet exists, return -1.

Function

getMaximumProfit(price: int[], profit: int[]) → int

Examples

Example 1

price = [1, 5, 3, 4, 6]profit = [2, 3, 4, 5, 6]return = 15

The optimal triplet is (3, 4, 5) in one-based indexing. Its prices satisfy 3 < 4 < 6, and its total profit is 4 + 5 + 6 = 15.

Example 2

price = [3, 2, 1]profit = [10, 20, 30]return = -1

No three indices have strictly increasing prices.

More Odoo interview questions

  • Compare Character Arrays with BackspacesOA · Seen Sep 2024
  • Employees Joined per MonthOA · Seen Sep 2024
  • Evaluate a Python Integer ExpressionOA · Seen Sep 2024
  • HTML Elements Single-Tag CorrectionOA · Seen Sep 2023
  • Same Binary TreePHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Rolling MetricsAkuna Capital · OAAkuna Capital interview questions
  • Longest Increasing Price SubsequenceOpenAI · OAOpenAI interview questions
  • Minimum Bridge TurnbacksBNSF Railway · OABNSF Railway interview questions
  • Minimum Cost to Attend Required CoursesVisa · OAVisa interview questions
  • Fill a Time Window with SongsMicrosoft · OAMicrosoft interview questions
  • Maximum Taxi EarningsWells Fargo · OAWells Fargo interview questions
  • Longest Increasing Subsequence from Two ArraysSquarepoint Capital · OASquarepoint Capital interview questions
  • Split Array Largest SumLinkedIn · OALinkedIn interview questions
  • Longest Increasing SubsequenceAtlassian · OAAtlassian interview questions
  • Longest Increasing Subsequence LengthApple · OAApple interview questions
All Odoo interview questionsSee Odoo hiring insights
Saved
class Solution {
    public int getMaximumProfit(int[] price, int[] profit) {
      // Write your code here.
    }
}
Checking account…