c++ | easy | fast
\n\n# Code\n\n\n  class Solution {\npublic:\n    int numSubarrayBoundedMax(vector<int>& nums, int left, int right) {\n        return count(nums, right) - count(
\n\n# Code\n```\n\n  class Solution {\npublic:\n    int numSubarrayBoundedMax(vector<int>& nums, int left, int right) {\n        return count(nums, right) - count(nums, left - 1);\n    }\n    int count(const vector<int>& nums, int bound) {\n        int ans = 0, cnt = 0;\n        for (int x : nums) {\n            cnt = x <= bound ? cnt + 1 : 0;\n            ans += cnt;\n        }\n        return ans;\n    }\n\n};\n```
['C++']