1D dp
in this solution we are storing ans   for every element in the dp array \nwe are breaking the array where the number which is bigger than r \nand for number sma
in this solution we are storing ans   for every element in the dp array \nwe are breaking the array where the number which is bigger than r \nand for number smaller than l ans will be of previous valid sequence \nand for the valid sequence ans will be the length from where last bigger than r element came \n\nand the total ans for solution will be the sum of all those answeres\n```\nclass Solution {\npublic:\n    int l , r;\n    bool check(int x ) \n    { \n        return (x>=l && x<=r);\n    }\n    bool isbig(int x) \n    { \n        return (x>r);\n    }\n    int numSubarrayBoundedMax(vector<int>& nums, int left, int right) {\n        int valid_id = 0 , invalid_bigid=0;\n        l = left,r=right;\n        int n = nums.size();\n        vector<int> dp(n+1);\n        //dp(i)->gives total number of ways to form substring such that ith char is the last one \n        for(int i =1;i<=n;i++)\n        { \n            if(check(nums[i-1]))\n            { \n                valid_id=i;\n                dp[i]=valid_id-invalid_bigid;\n            }\n            else \n            { \n                if(isbig(nums[i-1]))\n                { \n                    invalid_bigid=i;\n                }\n                if(invalid_bigid<valid_id)\n                { \n                    dp[i]=dp[valid_id];\n                }\n            }\n        }\n        int sum = 0 ;\n        for(int i  = 0 ;i<=n;i++)\n        { \n            sum+=dp[i];\n        }\n        return sum;\n       \n    }\n};\n```
['Two Pointers', 'Dynamic Programming', 'C']