O(n) time
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# 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```javascript []\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar minimumSum = function (nums, start = 0, end = nums.length) {\n  const leftMin = new Array(nums.length).fill(Infinity);\n  const rightMin = new Array(nums.length).fill(Infinity);\n  let currentMin = Infinity;\n  for (let i = 0; i < nums.length; i++) {\n    if (currentMin<nums[i]) leftMin[i] = currentMin;\n    currentMin = Math.min(currentMin, nums[i]);\n  }\n  currentMin= Infinity\n   for (let i = nums.length-1; i >=0; i--) {\n    if (nums[i]>currentMin) rightMin[i] = currentMin;\n    currentMin = Math.min(currentMin, nums[i]);\n  }\n  let minSum = Infinity\n   for (let i = 0; i < nums.length; i++) {\n   const minRes = nums[i] + leftMin[i]+rightMin[i]\n   if(minSum>minRes) minSum = minRes\n  }\n  \n  return minSum!==Infinity?minSum:-1\n};\n```
['JavaScript']