Easy & Beginner Friendly Solution || Beats 100% 
ProofIntuitionhe problem aims to find the minimum sum of three elements in the array nums, satisfying the condition nums[i] < nums[j] > nums[k], i.e., nums[j] i
# Proof
![Screenshot 2025-01-02 233953.png](https://assets.leetcode.com/users/images/9769c9ee-2116-410d-8688-98520143365e_1735841410.2337.png) 

# Intuition
he problem aims to find the minimum sum of three elements in the array nums, satisfying the condition nums[i] < nums[j] > nums[k], i.e., nums[j] is a peak value compared to nums[i] and nums[k]. This approach checks all possible triplets to find the valid one with the smallest sum.
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach

1. **Brute Force Iteration:**
 Use three nested loops to iterate through all possible triplets in the array.
For each triplet, check if nums[i] < nums[j] and nums[k] < nums[j].
If the condition is satisfied, calculate the sum of nums[i], nums[j], and nums[k], and compare it with the current minimum sum.

2. **Tracking the Minimum Sum:**
 Use a variable sum initialized to Integer.MAX_VALUE to keep track of the smallest valid sum.
If no valid triplet is found, return -1.

3. **Edge Cases:**
If the array length n is less than 3, no valid triplet can exist.

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

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

# Code
```java []
class Solution {
    public int minimumSum(int[] nums) {
        int n = nums.length; int sum = Integer.MAX_VALUE;
        for(int i =0; i<n-2; i++){
            for(int j = i+1; j<n-1;j++){
                for(int k = j+1; k<n; k++){
                    if(nums[i]< nums[j] && nums[k]<nums[j]){
                        int currentsum = nums[i]+ nums[j]+ nums[k];
                        sum = Math.min(currentsum, sum);
                    }
                }
            }
        }
        if(sum == Integer.MAX_VALUE){
            return -1;
        }
        return sum;
    }
}
```
['Java']