📌JAVA || Easy || Sliding window || O(n)✅
If it helps, do an Upvote \u2B06\uFE0F\uD83C\uDD99 So others can also find it helpful\n\nclass Solution {\n    public int numSubarrayBoundedMax(int[] nums, int 
**If it helps, do an Upvote \u2B06\uFE0F\uD83C\uDD99 So others can also find it helpful**\n```\nclass Solution {\n    public int numSubarrayBoundedMax(int[] nums, int left, int right) {\n        \n        int i=0;\n        int j=0;\n        int m=0;\n        int count=0;\n        \n        while(j<nums.length){\n            \n            if(nums[j] > right){\n                m=0;\n                i=j+1;\n            }\n            \n            if(nums[j]>=left && nums[j] <=right){\n                m = j-i+1;\n            }\n            count+=m;\n            j++;\n            \n            \n        }\n        \n        return count;\n        \n    }\n}\n```
['Sliding Window', 'Java']