Java&JS&TS Solution (JW)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\npublic int minimumSum(int[] nums) {\n    int n = nums.length;\n    int minSum = Integer.MAX_VALUE;\n    boolean hasMountain = false;\n\n    // Iterate through the middle element of the triplet (j)\n    for (int j = 1; j < n - 1; j++) {\n        int leftMin = Integer.MAX_VALUE;\n        int rightMin = Integer.MAX_VALUE;\n\n        // Find the smallest valid i (nums[i] < nums[j]) to the left of j\n        for (int i = 0; i < j; i++) {\n            if (nums[i] < nums[j]) {\n                leftMin = Math.min(leftMin, nums[i]);\n            }\n        }\n\n        // Find the smallest valid k (nums[k] < nums[j]) to the right of j\n        for (int k = j + 1; k < n; k++) {\n            if (nums[k] < nums[j]) {\n                rightMin = Math.min(rightMin, nums[k]);\n            }\n        }\n\n        // If valid i and k are found, calculate the mountain triplet sum\n        if (leftMin != Integer.MAX_VALUE && rightMin != Integer.MAX_VALUE) {\n            hasMountain = true;\n            int currentSum = leftMin + nums[j] + rightMin;\n            minSum = Math.min(minSum, currentSum);\n        }\n    }\n\n    // Return the minimum sum if a mountain triplet exists, otherwise -1\n    return hasMountain ? minSum : -1;\n}\n```\n```javascript []\nvar minimumSum = function(nums) {\n    const n = nums.length;\n    let minSum = Infinity;\n    let hasMountain = false;\n\n    // Iterate through the middle element of the triplet (j)\n    for (let j = 1; j < n - 1; j++) {\n        let leftMin = Infinity;\n        let rightMin = Infinity;\n\n        // Find the smallest valid i (nums[i] < nums[j]) to the left of j\n        for (let i = 0; i < j; i++) {\n            if (nums[i] < nums[j]) {\n                leftMin = Math.min(leftMin, nums[i]);\n            }\n        }\n\n        // Find the smallest valid k (nums[k] < nums[j]) to the right of j\n        for (let k = j + 1; k < n; k++) {\n            if (nums[k] < nums[j]) {\n                rightMin = Math.min(rightMin, nums[k]);\n            }\n        }\n\n        // If valid i and k are found, calculate the mountain triplet sum\n        if (leftMin !== Infinity && rightMin !== Infinity) {\n            hasMountain = true;\n            const currentSum = leftMin + nums[j] + rightMin;\n            minSum = Math.min(minSum, currentSum);\n        }\n    }\n\n    // Return the minimum sum if a mountain triplet exists, otherwise -1\n    return hasMountain ? minSum : -1;\n};\n```\n```typescript []\nfunction minimumSum(nums: number[]): number {\n    const n = nums.length;\n    let minSum = Infinity;\n    let hasMountain = false;\n\n    // Iterate through the middle element of the triplet (j)\n    for (let j = 1; j < n - 1; j++) {\n        let leftMin = Infinity;\n        let rightMin = Infinity;\n\n        // Find the smallest valid i (nums[i] < nums[j]) to the left of j\n        for (let i = 0; i < j; i++) {\n            if (nums[i] < nums[j]) {\n                leftMin = Math.min(leftMin, nums[i]);\n            }\n        }\n\n        // Find the smallest valid k (nums[k] < nums[j]) to the right of j\n        for (let k = j + 1; k < n; k++) {\n            if (nums[k] < nums[j]) {\n                rightMin = Math.min(rightMin, nums[k]);\n            }\n        }\n\n        // If valid i and k are found, calculate the mountain triplet sum\n        if (leftMin !== Infinity && rightMin !== Infinity) {\n            hasMountain = true;\n            const currentSum = leftMin + nums[j] + rightMin;\n            minSum = Math.min(minSum, currentSum);\n        }\n    }\n\n    // Return the minimum sum if a mountain triplet exists, otherwise -1\n    return hasMountain ? minSum : -1;\n};\n```
['Array', 'Java', 'TypeScript', 'JavaScript']