Tap here to switch tabs
Problem
Submissions

Problem: Maximum Value of an Ordered Triplet I

Maximum Value of an Ordered Triplet I asks you to choose three array elements in increasing index order and maximize the first minus second, multiplied by third, returning zero if all triplet values are negative.

Statement

You are given an integer array nums.

An ordered triplet of indices (i, j, k) is valid if i<j<ki < j < k. The value of this triplet is defined as (nums[i] −- nums[j]) ⋅\cdot nums[k].

Return the maximum value among all valid triplets. If all triplet values are negative, return 00.

Constraints:

  • 3≤3 \leq nums.length ≤100\leq 100

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Value of an Ordered Triplet I

Maximum Value of an Ordered Triplet I asks you to choose three array elements in increasing index order and maximize the first minus second, multiplied by third, returning zero if all triplet values are negative.

Statement

You are given an integer array nums.

An ordered triplet of indices (i, j, k) is valid if i<j<ki < j < k. The value of this triplet is defined as (nums[i] −- nums[j]) ⋅\cdot nums[k].

Return the maximum value among all valid triplets. If all triplet values are negative, return 00.

Constraints:

  • 3≤3 \leq nums.length ≤100\leq 100

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