Best Java Solution || Beats 98%
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n\n    // Taken Help\n    public int numSubarrayBoundedMax(int[] nums, int left, int right) {\n        int i = 0, j = 0, res = 0, maxind = -1;\n        while(j < nums.length){\n            if(nums[j] >= left && nums[j] <= right){\n                maxind = j;\n            }\n            if(nums[j] > right){\n                j++;\n                i = j;\n                maxind = -1;\n                continue;\n            }\n            if(maxind != -1){\n                res += maxind - i + 1;\n            }\n            j++;\n        }\n        return res;\n    }\n}\n```
['Java']