✅ C++ Solution - 2 pointers O(nlogn) TC O(n) SC ✅
Code\n\nclass Solution {\npublic:\n    int mod = 1e9+7;\n    vector<int> pow(int b,int n){\n        vector<int> power(n+1);\n        power[0]=1;\n        for(in
## Code\n```\nclass Solution {\npublic:\n    int mod = 1e9+7;\n    vector<int> pow(int b,int n){\n        vector<int> power(n+1);\n        power[0]=1;\n        for(int i=1;i<=n;i++){\n            power[i]=(power[i-1]*b)%mod;\n        }\n        return power;\n    }\n    int numSubseq(vector<int>& nums, int target) {\n        \n        int n=nums.size();\n        sort(nums.begin(),nums.end());\n\n        vector<int> power = pow(2,n);\n\n        int count=0;\n        //l=min, h=max\n        int l=0,h=n-1;\n        while(l<=h){\n            if(nums[l]+nums[h]<=target){\n                count = (count + power[h-l]%mod)%mod; \n                //minE should be present for sure\n                //rest all can be present or not\n                l++;\n            }\n            else    h--;\n        }\n        return count%mod;\n    }\n};\n```\nTo optimise further, use **Binary Exponentiation**.
['Array', 'Two Pointers', 'Sorting', 'C++']