Hints |  Approach | Explanation | C++
Approach\n\nIn this question, we have to find max. no. of subaarays whose maximum number is in the range [L,R] both inclusive.\n\nHere the idea is we keep to po
**Approach**\n\nIn this question, we have to find max. no. of subaarays whose maximum number is in the range [L,R] both inclusive.\n\nHere the idea is we keep to pointers to maintain a window (subarray) which is satisfying the condition.\nIf we see our window no longer satisfying the condition( i.e.max. of subarray is not in the range) then we change left and right accordingly.\n\n*When to change left and why  ?*\n\n If we see our max. element is greater than rightmost boundary means We can\'t continue with the  subarray anymore , so we update `left = i,` start i onwards\n \n *When to change right and why ?*\n \n If we see our current element is less than leftmost boundary means  we can form a subarray with curr element but not just with curr elem because currr elem < L.\n So,we will not update` right  = i`, \n Ex . (2 1 4 3 )\n here , when right is at 1,the no. of subarray with max in range = no. of subarrays with max in range when right is at 0\n \n \n So, if curr elem >= leftmost boundary ,then only we change right =i,\n and calulate no. of subarrays at every iteration.\n i.e  `result += right-left; `\n\n**CODE**\n\n```\n  int numSubarrayBoundedMax(vector<int>& A, int L, int R) {\n        int result=0, left=-1, right=-1;\n        for (int i=0; i<A.size(); i++) {\n            if (A[i]>R) left=i;\n            if (A[i]>=L) right=i;\n            result+=right-left;\n        }\n        return result;\n```
['C', 'C++']