Beginner Friendly Easy Python Code
Code\n\nclass Solution:\n    def minimumSum(self, nums: List[int]) -> int:\n        \n        if(len(nums) < 3):\n            return -1\n        \n        min_s
# Code\n```\nclass Solution:\n    def minimumSum(self, nums: List[int]) -> int:\n        \n        if(len(nums) < 3):\n            return -1\n        \n        min_sum = float(\'inf\')\n        \n        for i in range(1,len(nums)-1):\n            left_min = min(nums[:i])              # Maximum element on right side \n            right_min = min(nums[i+1:])           # Maximum element on left side \n            \n            if(nums[i] > left_min and nums[i] > right_min):\n                min_sum = min(min_sum , left_min + nums[i] + right_min)\n                \n        return min_sum if min_sum != float("inf") else -1\n```\n\n# Explanation\n\n1. The class Solution defines a method minimumSum(), which takes an array of integers nums as input and returns the minimum possible sum of a mountain triplet of nums, or -1 if no such triplet exists.\n\n2. If the length of nums is less than 3, then no mountain triplet can exist, so the function returns -1.\n\n3. Initialize the variable min_sum to infinity. This will store the minimum possible sum of a mountain triplet found so far.\n\n4. Iterate over the array nums from index 1 to index len(nums) - 2. For each index i, find the minimum elements on the left and right of i using the variables left_min and right_min, respectively.\n\n5. If the element nums[i] is greater than both left_min and right_min, then it is a possible peak element of a mountain triplet. In this case, update the variable min_sum to the minimum of min_sum and the sum of left_min, nums[i], and right_min.\n\n6. If min_sum is not equal to infinity, then a mountain triplet with minimum sum min_sum has been found. The function returns min_sum. Otherwise, the function returns -1 to indicate that no mountain triplet exists.\n\n\n##### If you find my solution helpful and worthy, please consider upvoting my solution. Upvotes play a crucial role in ensuring that this valuable content reaches others and helps them as well.\n\n##### Only your support motivates me to continue contributing more solutions and assisting the community further.\n\n##### Thank You for spending your valuable time.
['Array', 'Math', 'Python', 'Python3']