Minimum Sum of Mountain Triplets I

As a Systems Engineer at Tata Consultancy Services, I deliver exceptional software products for mobile and web platforms, using agile methodologies and robust quality maintenance. I am experienced in performance testing, automation testing, API testing, and manual testing, with various tools and technologies such as Jmeter, Azure LoadTest, Selenium, Java, OOPS, Maven, TestNG, and Postman.
I have successfully developed and executed detailed test plans, test cases, and scripts for Android and web applications, ensuring high-quality standards and user satisfaction. I have also demonstrated my proficiency in manual REST API testing with Postman, as well as in end-to-end performance and automation testing using Jmeter and selenium with Java, TestNG and Maven. Additionally, I have utilized Azure DevOps for bug tracking and issue management.
You are given a 0-indexed array nums of integers.
A triplet of indices (i, j, k) is a mountain if:
i < j < knums[i] < nums[j]andnums[k] < nums[j]
Return the minimum possible sum of a mountain triplet of nums. If no such triplet exists, return -1.
LeetCode Problem - 2908
class Solution {
// Method to find the minimum sum of a triplet where the elements are in increasing order of index
public int minimumSum(int[] nums) {
// Initialize the result variable with the maximum possible integer value
int result = Integer.MAX_VALUE;
// Loop through each element in the array
for (int i = 0; i < nums.length; i++) {
// Check the elements after the current element
for (int j = i + 1; j < nums.length; j++) {
// Check if the element at index i is less than the element at index j
if (nums[i] < nums[j]) {
// If yes, check the elements after index j
for (int k = j + 1; k < nums.length; k++) {
// Check if the element at index k is less than the element at index j
if (nums[k] < nums[j]) {
// If yes, calculate the sum of the triplet
int sum = nums[i] + nums[j] + nums[k];
// Update the result if the current sum is less than the previous result
if (sum < result) {
result = sum;
}
}
}
}
}
}
// If no valid triplet is found, return -1
if (result == Integer.MAX_VALUE)
return -1;
else
return result;
}
}




