C++| Very simple code
\n int atmost(vector<int>& A,int t)\n    {\n        int mx=INT_MIN;\n        int res=0;\n        int l=0;\n        for(int i=0;i<A.size();i++)\n        {\n     
```\n int atmost(vector<int>& A,int t)\n    {\n        int mx=INT_MIN;\n        int res=0;\n        int l=0;\n        for(int i=0;i<A.size();i++)\n        {\n            mx=max(mx,A[i]);\n            \n            if(mx>t)\n            {\n                while(l<=i)\n                {\n                    l=l+1;\n\n                }\n                mx=INT_MIN;\n            }\n            res+=i-l+1;\n        }\n        return res;\n        \n    }\n    int numSubarrayBoundedMax(vector<int>& A, int L, int R) {\n        \n        if(A.size()==0)\n        {\n            return 0;\n        }\n        \n        \n       return atmost(A,R)-atmost(A,L-1);\n        \n        \n    }\n};\n```
[]