Two Pointer Approach C++
\nclass Solution {\npublic:\n    int numSubarrayBoundedMax(vector<int>& nums, int left, int right) {\n        int i=0, j=0;\n        int count = 0;\n        int
```\nclass Solution {\npublic:\n    int numSubarrayBoundedMax(vector<int>& nums, int left, int right) {\n        int i=0, j=0;\n        int count = 0;\n        int prevCount=0;\n        int n=nums.size();\n       \n        while(j < n){\n            if(nums[j] >= left && nums[j] <= right){\n                prevCount= j-i+1;\n                count+=prevCount;\n            }else if(nums[j] < left){\n                count+=prevCount;\n            }else{\n                i=j+1;\n                prevCount=0;\n            }\n            j++;\n        }\n        \n        return count;\n    }\n};\n```
['C']