[Java] ✅ 1MS ✅ beats 100% ✅ PREFIX/SUFFIX MIN
Approach\n1. Traverse array with 2 indices i and j from 0 and n -1.\n2. Use two int[] leftMin[] and rightMin[] to keep track of lowest value of the left, right 
# Approach\n1. Traverse array with 2 indices i and j from 0 and n -1.\n2. Use two int[] leftMin[] and rightMin[] to keep track of lowest value of the left, right of each i and j.\n3. Traverse array and precompute the prefix lowest min for each i and lowest right side min for each j\n    - EG:[4,3,1,2,5,4]\n    - leftMin: [4,3,1,1,1,1]\n    - rightMin: [1,1,1,2,4,4]\n4. Traverse with i from 1 to n-1 and if nums[i] > leftMin[i-1] and nums[i] > rightMin[i+1] determine and keep the minSum\n5. Return minSum or -1;\n\n# Complexity\n- Time complexity:$$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int minimumSum(int[] nums) {\n        int[] leftMin = new int[nums.length];\n        int[] rightMin = new int[nums.length];\n        int prevLeft = Integer.MAX_VALUE, prevRight = Integer.MAX_VALUE;\n        for (int i = 0, j = nums.length -1; i < nums.length; i++, j--) {\n            leftMin[i] = Math.min(nums[i], prevLeft);\n            rightMin[j] = Math.min(nums[j], prevRight);\n            prevLeft = leftMin[i];\n            prevRight = rightMin[j];\n        }\n        int minSum = Integer.MAX_VALUE;\n        for (int i = 1; i < nums.length -1; i++) {\n            if (nums[i] > leftMin[i-1] && nums[i] > rightMin[i+1]) {\n                minSum = Math.min(minSum, leftMin[i-1] + nums[i] + rightMin[i+1]);\n            }\n        }\n        return minSum == Integer.MAX_VALUE ? -1 : minSum;\n    }\n}\n```
['Java']