O(n) solution beats 90% in C
\nint numSubarrayBoundedMax(int* nums, int numsSize, int left, int right){\n    \n    int l=0,r=0;\n    int count=0;\n    int prev=0;\n    while (r < numsSize)\
```\nint numSubarrayBoundedMax(int* nums, int numsSize, int left, int right){\n    \n    int l=0,r=0;\n    int count=0;\n    int prev=0;\n    while (r < numsSize)\n    {\n        if (nums[r] >= left && nums[r] <= right)\n        {\n            prev = r-l;\n            count = 1 + count + prev;\n        }\n        else\n        {\n            if (nums[r] > right)  \n            {\n                r++;\n                l=r;\n                prev=0;\n                continue;\n            }\n            else              \n            {\n                if (l!=r)\n                {\n                    if (nums[r-1] >= left && nums[r-1] <= right) \n                    {\n                        prev = r-l;\n\t\t\t\t\t}\n                    count = count + prev;\n                }\n            }\n        }\n        r++;\n    }\n    return count;\n}\n```
['C']