Tap here to switch tabs
Problem
Submissions

Problem: Maximum Value of an Ordered Triplet II

Try to solve the Maximum Value of an Ordered Triplet II problem.

Statement

You are given an integer array nums.

An ordered triplet consists of three indices (i, j, k) such that i << j << k. The value of such a triplet is evaluated as (nums[i] −- nums[j]) $ imes$ nums[k].

Return the maximum value among all ordered triplets in nums. If every triplet yields a negative value, return 00.

Constraints:

  • 3≤3 \leq nums.length ≤105\leq 10^5

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Value of an Ordered Triplet II

Try to solve the Maximum Value of an Ordered Triplet II problem.

Statement

You are given an integer array nums.

An ordered triplet consists of three indices (i, j, k) such that i << j << k. The value of such a triplet is evaluated as (nums[i] −- nums[j]) $ imes$ nums[k].

Return the maximum value among all ordered triplets in nums. If every triplet yields a negative value, return 00.

Constraints:

  • 3≤3 \leq nums.length ≤105\leq 10^5

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