2908. Minimum Sum of Mountain Triplets I Easy
1/**
2 * [2908] Minimum Sum of Mountain Triplets I
3 *
4 * You are given a 0-indexed array nums of integers.
5 * A triplet of indices (i, j, k) is a mountain if:
6 *
7 * i < j < k
8 * nums[i] < nums[j] and nums[k] < nums[j]
9 *
10 * Return the minimum possible sum of a mountain triplet of nums. If no such triplet exists, return -1.
11 *
12 * <strong class="example">Example 1:
13 *
14 * Input: nums = [8,6,1,5,3]
15 * Output: 9
16 * Explanation: Triplet (2, 3, 4) is a mountain triplet of sum 9 since:
17 * - 2 < 3 < 4
18 * - nums[2] < nums[3] and nums[4] < nums[3]
19 * And the sum of this triplet is nums[2] + nums[3] + nums[4] = 9. It can be shown that there are no mountain triplets with a sum of less than 9.
20 *
21 * <strong class="example">Example 2:
22 *
23 * Input: nums = [5,4,8,7,10,2]
24 * Output: 13
25 * Explanation: Triplet (1, 3, 5) is a mountain triplet of sum 13 since:
26 * - 1 < 3 < 5
27 * - nums[1] < nums[3] and nums[5] < nums[3]
28 * And the sum of this triplet is nums[1] + nums[3] + nums[5] = 13. It can be shown that there are no mountain triplets with a sum of less than 13.
29 *
30 * <strong class="example">Example 3:
31 *
32 * Input: nums = [6,5,4,3,4,5]
33 * Output: -1
34 * Explanation: It can be shown that there are no mountain triplets in nums.
35 *
36 *
37 * Constraints:
38 *
39 * 3 <= nums.length <= 50
40 * 1 <= nums[i] <= 50
41 *
42 */
43pub struct Solution {}
44
45// problem: https://leetcode.com/problems/minimum-sum-of-mountain-triplets-i/
46// discuss: https://leetcode.com/problems/minimum-sum-of-mountain-triplets-i/discuss/?currentPage=1&orderBy=most_votes&query=
47
48// submission codes start here
49
50impl Solution {
51 pub fn minimum_sum(nums: Vec<i32>) -> i32 {
52 0
53 }
54}
55
56// submission codes end
57
58#[cfg(test)]
59mod tests {
60 use super::*;
61
62 #[test]
63 fn test_2908() {
64 }
65}
66
Back
© 2025 bowen.ge All Rights Reserved.