Python O(n)
\n def numSubarrayBoundedMax(self, A, L, R):\n        """\n        :type A: List[int]\n        :type L: int\n        :type R: int\n        :rtype: int\n        
```\n def numSubarrayBoundedMax(self, A, L, R):\n        """\n        :type A: List[int]\n        :type L: int\n        :type R: int\n        :rtype: int\n        """\n        start = 0\n        lastMatch = None\n        count = 0\n        for idx in range(0, len(A)):\n            num = A[idx]\n            if num >= L and num <= R:\n                count += (idx - start) + 1\n                lastMatch = idx\n            elif num < L:\n                if lastMatch != None:\n                    count += (lastMatch - start) + 1\n            elif num > R:\n                start = idx + 1\n                lastMatch = None\n        return count\n```
[]