C++, O(n), <10 lines
class Solution { public:     int numSubarrayBoundedMax(vector<int>& A, int L, int R) {         int result=0, left=-1, right=-1;         for (int i=0; i<A.size()
```
class Solution {
public:
    int numSubarrayBoundedMax(vector<int>& A, int L, int R) {
        int result=0, left=-1, right=-1;
        for (int i=0; i<A.size(); i++) {
            if (A[i]>R) left=i;
            if (A[i]>=L) right=i;
            result+=right-left;
        }
        return result;
    }
};
```
[]