C++ O(n) Solution || leftMin + nums[i] + rightMin
Intuition\n Describe your first thoughts on how to solve this problem. \nTo get minimum sum for a mountain triplet we require the minimum numbers such that num[
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nTo get minimum sum for a mountain triplet we require the minimum numbers such that $$num[i] < nums[j]$$ & $$nums[j] > num[k]$$. To find these number we can find the right minimum and left miminum number for each index and return thr miminum sum.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nCreate 2 arrays $$leftMin$$ to find the minimum number from the left side and $$rightMin$$ to find the minimum numbers from the right side for each index.\n\nAfter finding the minimum numbers for each index traverse $$nums$$ and if $$nums[i]$$ is greater than both $$rightMin$$ and $$leftMin$$ find the sum and compare with the previous sum and return the minimum sum.\n\n# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    \n    int minimumSum(vector<int>& nums) \n    {\n        int n = nums.size();\n        vector<int> left(n, INT_MAX);\n        vector<int> right(n, INT_MIN);\n        \n        left[0] = nums[0];\n        for(int i=1; i<n; i++)\n            left[i] = min(left[i - 1], nums[i]);\n        \n        right[n-1] = nums[n-1];\n        for(int i=n-2; i>=0; i--)\n            right[i] = min(right[i+1], nums[i]);\n        \n        int ans = INT_MAX;\n        \n        for(int i=1; i<n-1; i++)\n        {\n            if(nums[i] > left[i-1] && nums[i] > right[i+1])\n            {\n                ans = min(ans, nums[i] + left[i-1] + right[i+1]);\n            }\n                \n        }\n        \n        return (ans == INT_MAX)?-1:ans;\n    }\n};\n```
['Array', 'Suffix Array', 'C++']