@@ -0,0 +1,989 @@
+# Time:  O(n)%0A# Space: O(1)%0A%0A# We are given an array A of positive integers,%0A# and two positive integers L and R (L %3C= R).%0A#%0A# Return the number of (contiguous, non-empty) subarrays%0A# such that the value of the maximum array element in that subarray is at least L and at most R.%0A#%0A# Example :%0A# Input: %0A# A = %5B2, 1, 4, 3%5D%0A# L = 2%0A# R = 3%0A# Output: 3%0A# Explanation: There are three subarrays that meet the requirements: %5B2%5D, %5B2, 1%5D, %5B3%5D.%0A#%0A# Note:%0A# - L, R  and A%5Bi%5D will be an integer in the range %5B0, 10%5E9%5D.%0A# - The length of A will be in the range of %5B1, 50000%5D.%0A%0Aclass Solution(object):%0A    def numSubarrayBoundedMax(self, A, L, R):%0A        %22%22%22%0A        :type A: List%5Bint%5D%0A        :type L: int%0A        :type R: int%0A        :rtype: int%0A        %22%22%22%0A        def count(A, bound):%0A            result, curr = 0, 0%0A            for i in A :%0A                curr = curr + 1 if i %3C= bound else 0%0A                result += curr%0A            return result%0A%0A        return count(A, R) - count(A, L-1)%0A

Create number-of-subarrays-with-bounded-maximum.py