cpp solution two pointers + math
\n\n\nclass Solution {\npublic:\n    int numSubseq(vector<int> &nums, int target) {\n        sort(nums.begin(), nums.end());   \n        long long ret = 0;\n   
```\n\n\nclass Solution {\npublic:\n    int numSubseq(vector<int> &nums, int target) {\n        sort(nums.begin(), nums.end());   \n        long long ret = 0;\n        int left = 0, right = nums.size() - 1;\n        while(left <= right) {\n            if(nums[left] + nums[right] > target) right--;\n            else {\n                ret += exp(2, (right - left++), 1000000007);\n                ret %= 1000000007;\n            }\n        }\n        return (int) ret;\n    }\nprivate:\n    int exp(int b, int exponent, int MOD) {\n        int result = 1; \n        unsigned long long int base = b % MOD; \n        while(exponent > 0) {\n            if (exponent % 2 == 1) {\n                result = (result * base) % MOD; \n            }\n            exponent = exponent >> 1; \n            base = (base * base) % MOD; \n        }\n        return result; \n    }\n};\n```
[]