795-Number of Subarrays with Bounded Maximum-Py All-in-One by Talse
Get it Done, Make it Better, Share the Best -- Talse\nI). Slide Window\n| O(T): O(n) | O(S): O(1) | Rt: 340ms | \npython\n    def numSubarrayBoundedMax(self, A:
**Get it Done, Make it Better, Share the Best -- Talse**\n**I). Slide Window**\n| O(T): O(n) | O(S): O(1) | Rt: 340ms | \n```python\n    def numSubarrayBoundedMax(self, A: List[int], L: int, R: int) -> int:\n        rst = count = st = 0; \n        for i in range(len(A)):\n            if L <= A[i] <= R: \n                count = i - st + 1\n                rst += count\n            elif A[i] < L: rst += count\n            else: count, st = 0, i+1\n        return rst\n```\nReferrence: https://leetcode.com/problems/number-of-subarrays-with-bounded-maximum/discuss/117595/Short-Java-O(n)-Solution\n\n
[]