2 Pointers easy approach
Intuition\n Describe your first thoughts on how to solve this problem. \nWe need to think of the subsequences having sum of minimum and maximum element less tha
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe need to think of the subsequences having sum of minimum and maximum element less than the target. For this we use the two pinter approach.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Initially we consider 2 pointers low and high pointing to first element and last element\n2. If the sum of those is greater than target, we decrement the high pointer\n3. Else we will find out the number of subsequences generated with the formula 2 power n\n\n# Complexity\n- Time complexity:O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    long long int MOD = 1e9+7;\n    int numSubseq(vector<int>& nums, int target) {\n        int N = nums.size();\n        int l = 0, h = N-1;\n        int ans=0;\n        \n        vector<int> p(N,1);\n        p[0]=1;\n        for(int i=1;i<N;i++)\n        p[i] = (p[i-1]*2)%MOD;\n\n        sort(nums.begin(),nums.end());\n        while(l<=h)\n        {\n            int req = nums[l] + nums[h];\n            if(req>target)\n            {\n                h--;\n            }\n            else\n            {\n                ans += p[h-l];\n                ans %= MOD;\n\n                l++;\n            }\n        }\n\n        return ans;\n    }\n};\n```
['C++']