Java | Sliding Window
It would be little tricky to find subarrays with maximum value b/w a specific range. But, finding subarrays with maximum value till a max specified value would 
It would be little tricky to find subarrays with maximum value b/w a specific range. But, finding subarrays with maximum value till a max specified value would be easy. So, what we could do is find number of subarrays with maximum value less than equal to **right** and find number of subarrays with maximum value less than equal to **left - 1**. Then by subtracting the second one from first one would be our answer. \nTime Complexity -> **O(n)** \nSpace Complexity -> **O(1)**\n\n```\nclass Solution {\n    public int numSubarrayBoundedMax(int[] nums, int left, int right) {\n        return subarraysWithMax(nums, right) - subarraysWithMax(nums, left - 1);\n    }\n    \n    private int subarraysWithMax(int[] nums, int max) {\n        int n = nums.length;\n        int i = 0, j = 0, count = 0, maxTillNow = Integer.MIN_VALUE;\n        \n        while(j < n) {\n            maxTillNow = Math.max(maxTillNow, nums[j]);\n            \n            if(maxTillNow <= max) {\n                count += (j - i + 1);\n            } else {\n                i = j + 1;\n                maxTillNow = Integer.MIN_VALUE;\n            }\n            j++;\n        }\n        \n        return count;\n    }\n} \n```
['Sliding Window', 'Java']