2908. Minimum Sum of Mountain Triplets I
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def minimumSum(self, nums: List[int]) -> int:
        n = len(nums)
        min_sum = float('inf')  # Initialize with infinity
        
        # Iterate through each possible peak (middle element of the triplet)
        for j in range(1, n - 1):
            # Find the minimum value on the left of j (nums[i] where i < j)
            left_min = float('inf')
            for i in range(j):
                if nums[i] < nums[j]:
                    left_min = min(left_min, nums[i])
            
            # Find the minimum value on the right of j (nums[k] where k > j)
            right_min = float('inf')
            for k in range(j + 1, n):
                if nums[k] < nums[j]:
                    right_min = min(right_min, nums[k])
            
            # If we found valid left and right values, compute the sum
            if left_min != float('inf') and right_min != float('inf'):
                min_sum = min(min_sum, left_min + nums[j] + right_min)
        
        # If no valid triplet was found, return -1
        return min_sum if min_sum != float('inf') else -1

```
['Python3']