Easy C++ Solution | Easy to Understand
\n# Code\n\n#define mod 1000000007\nclass Solution {\npublic:\n    long long power(long long base,long long n){\n        long long ans=1;\n        while(n!=0){\
\n# Code\n```\n#define mod 1000000007\nclass Solution {\npublic:\n    long long power(long long base,long long n){\n        long long ans=1;\n        while(n!=0){\n            if(n%2==1){\n                ans=(ans*base)%mod;\n                n--;\n            }else{\n                base=(base*base)%mod;\n                n=n/2;\n            }\n        }\n        return ans;\n    }\n    int numSubseq(vector<int>& nums, int target) {\n        int i=0;\n        int j=nums.size()-1;\n        sort(nums.begin(),nums.end());\n        long long ans=0;\n\n        while(i<=j){\n            if(nums[i]+nums[j]<=target){\n                long long temp=power(2,j-i);\n                ans=(ans+temp)%mod;\n                i++;\n            }\n            else {\n                j--;\n            }\n        }\n\n        return ans;\n    }\n};\n```
['C++']