MONTONIC STACK OPPP
**Bold**# 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# Complexit
****************Bold****************# 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```\nclass Solution:\n    def numSubarrayBoundedMax(self, nums: List[int], left: int, right: int) -> int:\n        inf = 2**32\n        nums = [inf]+nums+[inf]\n        stack=[]\n        count=0 \n\n        \n        for i,x in enumerate(nums):\n\n                while stack and nums[stack[-1]] < x:\n                    \n                    j =stack.pop()\n                    k= stack[-1]\n\n                    if left<=nums[j]<=right:\n                        count+=(i-j)*(j-k)\n                stack.append(i)\n        return count\n\n\n        \n```
['Python3']