minLeft and minRight, of the same length as nums.minLeft such that minLeft[i] contains the minimum value in nums to the left of index i.minRight such that minRight[i] contains the minimum value in nums to the right of index i.minSum to track the minimum sum of a mountain triplet, and set it to a very large value initially.nums array from the second element to the second-to-last element.nums[i], check if it is greater than both minLeft[i] and minRight[i].nums[i] + minLeft[i] + minRight[i]) and update minSum if this sum is smaller.minSum was updated. If it was not, return -1 to indicate no mountain triplet was found. Otherwise, return minSum.