Skip to content

Practice Minimum Sum of Mountain Triplets II

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

Medium#2909
LeetCode Problem

Minimum Sum of Mountain Triplets II

Problem Statement

Choose indices i < j < k such that nums[i] < nums[j] and nums[k] < nums[j]. Return the smallest possible sum of these three entries, or -1 if no such triplet exists.

Source: Minimum Sum of Mountain Triplets II on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [8,6,1,5,3]
Output
9

# Example 2

Input
nums = [5,4,8,7,10,2]
Output
13

# Example 3

Input
nums = [6,5,4,3,4,5]
Output
-1

Constraints

3 <= nums.length <= 10^5
1 <= nums[i] <= 10^8

Related LeetCode Problems

Practice more problems similar to Minimum Sum of Mountain Triplets II.

Review your practice with PhantomCodeAI

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