C++ Solution || Sliding Window || Easy to understand
we first sort the array to keep out minimum element at position and find the maximum subarrays that follow the condition.\nthe approach is similar to that of th
we first sort the array to keep out minimum element at position and find the maximum subarrays that follow the condition.\nthe approach is similar to that of the sliding window solution of the two sum problem.\nWhenever our sum is less than or equals to the target sum then we count the number of the subarrays.\n\nLets say our (right - left) is of length l then the solution in this array will be 2^(right - left) (take the element or dont take the element).\n\t\n\tint numSubseq(vector<int>& nums, int target) {\n        int n = nums.size();\n        \n        sort(nums.begin(), nums.end());\n        int l = 0;\n        int r = n-1;\n        int ans = 0;\n        int mod = 1e9 + 7;\n        \n        vector<int> pow(n,1);\n        \n        for(int i=1; i<n; i++){\n            pow[i] = (pow[i-1] * 2) % mod;   \n        }\n        \n        while(l <= r){\n            if(nums[l] + nums[r] > target){\n                r--;\n            }\n            else{\n                ans = (ans + pow[r - l]) % mod;\n                l++;\n            }\n        }\n        \n        return ans;\n    }
['C', 'Sliding Window']