[Python 3] Monotomic Stack + Prefix Sum - Simple
Intuition\nsimilar to this problem: https://leetcode.com/problems/largest-rectangle-in-histogram/\n Describe your first thoughts on how to solve this problem. \
# Intuition\nsimilar to this problem: https://leetcode.com/problems/largest-rectangle-in-histogram/\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: $$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    def maxSumMinProduct(self, nums: List[int]) -> int:\n        mod = 10 ** 9 + 7\n        ps = [0]\n        stack = [-1]\n        nums.append(0)\n        res = 0\n        \n        for i in range(len(nums)):\n            while nums[stack[-1]] > nums[i]:\n                min_val = nums[stack.pop()]\n                range_sum = ps[i] - ps[stack[-1] + 1]\n                res = max(res, range_sum * min_val)\n            stack.append(i)\n            ps.append(ps[-1] + nums[i])\n        return res % mod\n```
['Monotonic Stack', 'Prefix Sum', 'Python3']