Linear Solution | 100% beats
IntuitionApproachComplexity
Time complexity:O(n)

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

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

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

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

# Code
```java []
class Solution {
    public int minimumSum(int[] nums) {
        int tripletSum = Integer.MAX_VALUE;
        int n = nums.length;
        int[] leftMin = new int[n];
        int[] rightMin = new int[n];
        leftMin[0] = Integer.MAX_VALUE;
        rightMin[n-1] = Integer.MAX_VALUE;
        for(int i=1; i<n; i++){
            leftMin[i] = Math.min(leftMin[i-1], nums[i-1]);
            rightMin[n-1-i] = Math.min(rightMin[n-i], nums[n-i]);
        }
        for(int i=1; i<nums.length-1; i++){
            if(leftMin[i]<nums[i] && rightMin[i] < nums[i]){
                tripletSum = Math.min(tripletSum, nums[i]+leftMin[i]+rightMin[i]);
            }
        }
        return tripletSum==Integer.MAX_VALUE ? -1 : tripletSum;
    }
}
```
['Java']