Tap here to switch tabs
Problem
Submissions

Problem: Maximum Increasing Triplet Value

Try to solve the Maximum Increasing Triplet Value problem.

Statement

You are given an integer array nums.

A triplet of indices (i, j, k) is called an increasing triplet if:

  • i << j << k

  • nums[i] << nums[j] << nums[k]

The value of an increasing triplet (i, j, k) is equal to nums[i] - nums[j] + nums[k].

Return the maximum value among all increasing triplets in nums.

Constraints:

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

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • The input is generated such that at least one triplet meets the given condition.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Increasing Triplet Value

Try to solve the Maximum Increasing Triplet Value problem.

Statement

You are given an integer array nums.

A triplet of indices (i, j, k) is called an increasing triplet if:

  • i << j << k

  • nums[i] << nums[j] << nums[k]

The value of an increasing triplet (i, j, k) is equal to nums[i] - nums[j] + nums[k].

Return the maximum value among all increasing triplets in nums.

Constraints:

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

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • The input is generated such that at least one triplet meets the given condition.