Skip to content

Practice Maximum Value of an Ordered Triplet I

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2873
LeetCode Problem

Maximum Value of an Ordered Triplet I

Problem Statement

You are given a 0-indexed integer array nums. Return the maximum value over all triplets of indices (i, j, k) such that i < j < k. If all such triplets have a negative value, return 0. The value of a triplet of indices (i, j, k) is equal to (nums[i] - nums[j]) * nums[k].

Source: Maximum Value of an Ordered Triplet I on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [12,6,1,2,7]
Output
77

# Example 2

Input
nums = [1,10,3,4,19]
Output
133

# Example 3

Input
nums = [1,2,3]
Output
0

Constraints

3 <= nums.length <= 100
1 <= nums[i] <= 10^6

Related LeetCode Problems

Practice more problems similar to Maximum Value of an Ordered Triplet I.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.