Best Explanation <10 lines || 2 pointer approach, No DP || Easy-Understanding
//FOR 1ST TEST CASE GIVEN IN QUESTUON-> FIND NUMBER OF SUBARRAYS WITH MAX ELEMENT GREATER THAN 1 AND SUBTRACT ALL THE SUBARRAYS WITH MAX ELEMENT GREATER THAN 3 
//FOR 1ST TEST CASE GIVEN IN QUESTUON-> FIND NUMBER OF SUBARRAYS WITH MAX ELEMENT GREATER THAN 1 AND SUBTRACT ALL THE SUBARRAYS WITH MAX ELEMENT GREATER THAN 3 FROM IT\n//THIS WILL GIVE YOU ALL SUBARRAYS WITH MAX ELEMENT IN RANGE [2,3]\n//FOR [2,1,4,3] THERE WILL BE 9 SUBARRAYS I.E 2, 21 , 214 , 2143 , 14 , 4 , 143 , 43 , 3 FOR MAX ELEMENT GREATER THAN 1 AND 6 SUBARRAYS FOR GREATER THAN 3 I.E 214 , 14 , 4 ,2143 ,143 , 43\n\n\nclass Solution {\npublic:\n    \n    int countSubarray(vector<int>& nums,int x){\n        \n       long long ans=0;\n        int idx=-1;\n        \n        for(int i=0;i<nums.size();i++){\n            \n            if(nums[i]>x){\n                idx=i;\n            }\n               \n             ans+=idx+1;\n        }\n        return ans;\n    }\n    \n    int numSubarrayBoundedMax(vector<int>& nums, int left, int right) {\nlong long ans=countSubarray(nums,left-1)-countSubarray(nums,right);\n        return int(ans);\n    }\n};\n\n//Pls upvote if you like my solution\n//Happy Coding : )
['C', 'C++']