Java: Sliding Window
```\nclass Solution {\n    public int numSubarrayBoundedMax(int[] nums, int left, int right) {\n        int count = 0;\n        int i = 0;\n        int j = 0;\n
```\nclass Solution {\n    public int numSubarrayBoundedMax(int[] nums, int left, int right) {\n        int count = 0;\n        int i = 0;\n        int j = 0;\n        int windowSize = 0; \n        \n        while(j < nums.length){\n            if(nums[j]>=left && nums[j]<=right){\n                windowSize = j - i + 1; \n            }else if(nums[j] > right){\n                windowSize = 0;\n                i = j + 1;\n            }\n            count+= windowSize;\n            j++;\n        }\n        return count;\n    }\n}
[]