C++ two pointer approach , Time-O(nlogn)
class Solution {\npublic:\n    int calpow(int a,int b)\n    {\n        if(b==0)return 1;\n        \n        int res=calpow(a,b/2);\n        \n        if(b%2==0)
class Solution {\npublic:\n    int calpow(int a,int b)\n    {\n        if(b==0)return 1;\n        \n        int res=calpow(a,b/2);\n        \n        if(b%2==0)\n        {\n            res=res*res;\n        }\n        else\n        {\n            res=res*a*res;\n        }\n        return res;\n    }\n    \n    int numSubseq(vector<int>& nums, int target) \n    {\n        int mod=1000000007;\n        int n=nums.size();\n        int i=0,j=n-1;\n        int ans=0;\n        \n         vector<int> pow(n,1);\n    \n         for(int i=1; i<n; i++)\n         {\n               pow[i] = (pow[i-1] * 2) % mod;   \n         }\n        \n        sort(nums.begin(),nums.end());\n        \n        while(i<=j)\n        {\n            if(nums[i]+nums[j]>target)j--;\n            \n            else\n            {\n                ans=(ans+pow[j-i])%mod;\n                i++;\n            }\n        }\n        return ans;\n    }\n};
['Sorting']