C++ solution | O(N) - Time complexity
\nclass Solution {\npublic:\n    int numSubarrayBoundedMax(vector<int>& nums, int left, int right) {\n        int n =  nums.size();\n        int si =0;//startin
```\nclass Solution {\npublic:\n    int numSubarrayBoundedMax(vector<int>& nums, int left, int right) {\n        int n =  nums.size();\n        int si =0;//starting index\n        int ei = 0; //ending index\n        int result =0, prev_count =0;\n        while(ei < n){\n            if(left <= nums[ei]  &&  nums[ei]<= right){\n              prev_count = ei- si +1;\n              result += prev_count;\n            }else if (  nums[ei] < left){\n                 result += prev_count;\n            }else{\n                //right < nums[ei]\n                si = ei +1;\n                prev_count =0;\n            }\n            ei++;\n       }\n      return result;\n    }\n};\n```
['C', 'C++']